:root {
  --bg-deep: #140f0c;
  --glass-bg: rgba(24, 18, 14, 0.58);
  --glass-bg-strong: rgba(20, 15, 11, 0.78);
  --glass-border: rgba(235, 209, 154, 0.28);
  --ivory: #faf5ed;
  --cream: #e8dccb;
  --muted: #cabba6;
  --gold-bright: #ecd092;
  --gold-main: #d1aa5c;
  --gold-deep: #a57f37;
  --sage: #8da284;
  --success: #629a74;
  --error: #df7b71;
  --radius-card: 28px;
  --radius-pill: 999px;
  --shadow-card: 0 28px 80px rgba(8, 5, 3, 0.65);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg-deep);
  color: var(--ivory);
  font-family: var(--font-sans);
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* Background stage */
.bg-stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg-deep);
}

.bg-poster-fallback,
.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.bg-video {
  transition: opacity 0.8s ease;
}

.bg-video.is-paused {
  opacity: 0;
}

.bg-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 20%, rgba(212, 170, 92, 0.14), transparent 58%),
    linear-gradient(180deg, rgba(16, 11, 8, 0.45) 0%, rgba(16, 11, 8, 0.62) 55%, rgba(12, 8, 6, 0.84) 100%);
  backdrop-filter: blur(2px);
}

/* Page layout */
.page-shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.card {
  position: relative;
  width: 100%;
  max-width: 490px;
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(130%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 245, 224, 0.18);
  padding: 32px 24px 24px;
  overflow: hidden;
  animation: cardRise 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.card-glow {
  position: absolute;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  height: 220px;
  background: radial-gradient(ellipse, rgba(236, 208, 146, 0.22), transparent 70%);
  pointer-events: none;
}

/* Hero */
.hero {
  position: relative;
  text-align: center;
  animation: fadeSlide 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.eyebrow {
  margin: 0 0 18px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--gold-bright);
}

.portrait-arch {
  width: 158px;
  height: 204px;
  margin: 0 auto 20px;
  padding: 5px;
  border-radius: 90px 90px 22px 22px;
  background: linear-gradient(155deg, rgba(236, 208, 146, 0.7), rgba(165, 127, 55, 0.22) 60%, rgba(236, 208, 146, 0.45));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
}

.portrait-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  border-radius: 86px 86px 18px 18px;
  background-color: #2b221b;
}

.couple-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.15rem, 8.2vw, 2.85rem);
  line-height: 1.08;
  letter-spacing: 0.01em;
  color: var(--ivory);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
}

.couple-title .amp {
  font-style: italic;
  font-weight: 400;
  color: var(--gold-bright);
  padding: 0 2px;
}

.date-pill {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 14px auto 18px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  color: var(--gold-bright);
}

.date-line {
  display: inline-block;
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(236, 208, 146, 0.8), transparent);
}

.welcome-copy {
  margin: 0 auto 24px;
  max-width: 39ch;
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--cream);
}

/* Upload controls */
.upload-section {
  position: relative;
  animation: fadeSlide 0.95s cubic-bezier(0.22, 1, 0.36, 1) 0.18s both;
}

.field-group {
  margin-bottom: 16px;
  text-align: left;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ivory);
}

.optional-tag {
  font-weight: 400;
  color: var(--muted);
}

.field-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(235, 209, 154, 0.25);
  background: rgba(14, 10, 8, 0.54);
  color: var(--ivory);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.field-input::placeholder {
  color: rgba(202, 187, 166, 0.56);
}

.field-input:focus {
  outline: none;
  border-color: var(--gold-bright);
  background: rgba(14, 10, 8, 0.72);
  box-shadow: 0 0 0 3px rgba(212, 170, 92, 0.22);
}

.field-input.is-invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(223, 123, 113, 0.2);
}

.field-hint {
  margin: 6px 2px 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.field-hint.is-error {
  color: #f3a8a0;
}

.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 14px 22px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #ecd092 0%, #cfa450 55%, #ba8c39 100%);
  color: #1c140d;
  font-family: var(--font-sans);
  font-size: 1.03rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(190, 143, 60, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, filter 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary::after {
  content: '';
  position: absolute;
  top: 0;
  left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.36), transparent);
  transform: skewX(-20deg);
  transition: left 0.65s ease;
}

.btn-primary:hover::after {
  left: 130%;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 11px 18px;
  border-radius: 14px;
  border: 1px solid rgba(236, 208, 146, 0.42);
  background: rgba(212, 170, 92, 0.14);
  color: var(--gold-bright);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.btn-secondary:active {
  transform: scale(0.985);
}

.format-note {
  margin: 10px 0 0;
  text-align: center;
  font-size: 0.76rem;
  color: var(--muted);
}

/* Status & Notices */
.status-banner,
.notice-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(19, 14, 11, 0.74);
  border: 1px solid rgba(223, 123, 113, 0.45);
  color: #f6c2bc;
  font-size: 0.87rem;
  text-align: center;
}

.notice-box {
  border-color: rgba(235, 209, 154, 0.32);
  color: var(--cream);
}

.notice-text {
  margin: 0;
}

/* Progress area */
.progress-area {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(235, 209, 154, 0.16);
}

.overall-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 0.86rem;
}

.overall-label {
  color: var(--ivory);
  font-weight: 500;
}

.overall-percent {
  color: var(--gold-bright);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #c99d49, #f1d9a0);
  transition: width 0.22s ease;
}

.retry-row {
  margin-top: 14px;
}

/* Preview grid */
.preview-grid {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 310px;
  overflow-y: auto;
}

.thumb-card {
  position: relative;
  border-radius: 12px;
  background: rgba(14, 10, 8, 0.72);
  border: 1px solid rgba(235, 209, 154, 0.18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.thumb-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: rgba(34, 26, 20, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-badge-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  color: var(--gold-bright);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}

.thumb-badge-fallback svg {
  width: 24px;
  height: 24px;
  opacity: 0.85;
}

.thumb-meta {
  padding: 6px 7px 7px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.thumb-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  font-size: 0.67rem;
  color: var(--muted);
}

.thumb-status {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thumb-status.is-done {
  color: #8fd1a3;
}

.thumb-status.is-failed {
  color: #f4a49c;
}

.thumb-status.is-uploading {
  color: var(--gold-bright);
}

.thumb-bar {
  width: 100%;
  height: 4px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.thumb-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--gold-main);
  transition: width 0.2s ease, background-color 0.2s ease;
}

.thumb-bar-fill.is-done {
  background: var(--success);
}

.thumb-bar-fill.is-failed {
  background: var(--error);
}

/* Done box */
.done-box {
  text-align: center;
  padding: 12px 0 4px;
  animation: fadeSlide 0.55s ease both;
}

.done-badge {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(98, 154, 116, 0.22);
  border: 1px solid rgba(143, 209, 163, 0.55);
  color: #9be0b0;
}

.done-badge svg {
  width: 28px;
  height: 28px;
}

.done-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ivory);
}

.done-summary {
  margin: 0 0 22px;
  font-size: 0.92rem;
  color: var(--cream);
}

.card-footer {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid rgba(235, 209, 154, 0.14);
  text-align: center;
  font-size: 0.72rem;
  color: rgba(202, 187, 166, 0.8);
  letter-spacing: 0.02em;
}

@keyframes cardRise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 390px) {
  .card {
    padding: 26px 18px 20px;
    border-radius: 22px;
  }

  .portrait-arch {
    width: 138px;
    height: 178px;
  }

  .preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .hero,
  .upload-section,
  .done-box {
    animation: none;
  }

  .btn-primary::after {
    display: none;
  }
}
