:root {
  --cream: #fbf6f0;
  --cream-dark: #f3e9df;
  --ink: #2c2420;
  --ink-soft: #6b5f57;
  --rose: #c58b8b;
  --rose-dark: #a86a6a;
  --gold: #b9925a;
  --line: #e8dcd0;
  --white: #ffffff;
  --shadow: 0 10px 30px rgba(44, 36, 32, 0.12);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Loading screen ---------- */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity .5s ease;
}
#loading-screen.fade-out { opacity: 0; pointer-events: none; }
#loading-screen p { color: var(--ink-soft); font-size: 14px; letter-spacing: .03em; }
.loading-heart {
  font-size: 32px;
  color: var(--rose);
  animation: heartbeat 1.1s ease-in-out infinite;
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 72px 24px 48px;
  text-align: center;
  background: linear-gradient(180deg, var(--cream-dark) 0%, var(--cream) 100%);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.hero-inner { max-width: 760px; margin: 0 auto; position: relative; z-index: 2; }
.hero-kicker {
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 14px;
  font-weight: 600;
}
.hero-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: clamp(42px, 9vw, 84px);
  margin: 0;
  line-height: 1.05;
  color: var(--ink);
}
.hero-title .amp {
  font-style: italic;
  color: var(--rose-dark);
  font-weight: 500;
  padding: 0 .1em;
}
.hero-sub {
  margin: 18px 0 0;
  font-size: 16px;
  color: var(--ink-soft);
}

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(251, 246, 240, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: var(--rose-dark);
  color: #fff;
  box-shadow: 0 4px 14px rgba(168, 106, 106, 0.35);
}
.btn-primary:hover { background: var(--rose); }
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--cream-dark); }
.btn-ghost-light {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.3);
}
.btn-ghost-light:hover { background: rgba(255,255,255,0.22); }
.btn-wide { width: 100%; justify-content: center; display: flex; }
.hidden { display: none !important; }

.selection-count {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ---------- Gallery grid ---------- */
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}
.photo-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--cream-dark);
  box-shadow: 0 1px 4px rgba(44,36,32,0.08);
}
.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .35s ease, transform .3s ease;
}
.photo-tile img.loaded { opacity: 1; }
.photo-tile:hover img { transform: scale(1.05); }
.photo-tile .tile-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(44,36,32,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.gallery-grid.select-mode .photo-tile .tile-check { opacity: 1; }
.photo-tile.selected .tile-check { background: var(--rose-dark); border-color: var(--rose-dark); }
.gallery-grid.select-mode .photo-tile.selected { outline: 3px solid var(--rose-dark); outline-offset: -3px; }
.gallery-grid.select-mode .photo-tile::after {
  content: "";
  position: absolute; inset: 0;
  background: rgba(44,36,32,0.08);
  opacity: 0;
  transition: opacity .15s;
}
.gallery-grid.select-mode .photo-tile.selected::after { opacity: 1; }

.empty-state { text-align: center; color: var(--ink-soft); padding: 60px 0; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 36px 20px 50px;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(20, 15, 12, 0.96);
  display: flex;
  flex-direction: column;
}
.lb-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 60px 70px;
  position: relative;
}
.lb-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border-radius: 4px;
}
.lb-close, .lb-nav {
  position: absolute;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255,255,255,0.2); }
.lb-close { top: 16px; right: 16px; width: 42px; height: 42px; font-size: 22px; z-index: 5; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 50px; height: 50px; font-size: 26px; z-index: 5; }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }
.lb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(0,0,0,0.3);
  flex-wrap: wrap;
  gap: 10px;
}
.lb-counter { color: rgba(255,255,255,0.7); font-size: 13px; font-weight: 600; }
.lb-actions { display: flex; gap: 10px; }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(20, 15, 12, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 920px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-header h2 { margin: 0; font-family: 'Playfair Display', serif; font-size: 22px; }
.modal-close {
  background: none; border: none; font-size: 24px; cursor: pointer; color: var(--ink-soft);
  width: 32px; height: 32px;
}
.crop-body { display: flex; gap: 20px; padding: 20px; flex-wrap: wrap; }
.crop-canvas-wrap {
  flex: 1 1 480px;
  min-width: 280px;
  max-height: 60vh;
  background: #1c1512;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
}
.crop-canvas-wrap img { max-width: 100%; display: block; }
.crop-controls { flex: 0 0 220px; display: flex; flex-direction: column; gap: 10px; }
.crop-label { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin: 0; text-transform: uppercase; letter-spacing: .05em; }
.ratio-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.ratio-btn {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--cream);
  cursor: pointer;
  color: var(--ink);
}
.ratio-btn.active { background: var(--rose-dark); color: #fff; border-color: var(--rose-dark); }
.crop-hint { font-size: 13px; color: var(--ink-soft); margin: 4px 0; }

.crop-progress {
  position: relative;
  background: var(--cream-dark);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  margin: 8px 0;
}
.crop-progress-bar {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: var(--rose-dark);
  transition: width .2s ease;
}
.crop-progress span, #zip-progress-text {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
  text-align: center;
}

.zip-card { max-width: 420px; text-align: center; padding: 30px 26px; }
.zip-note { font-size: 13px; color: var(--ink-soft); margin-top: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 400;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  box-shadow: var(--shadow);
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .hero { padding: 48px 16px 32px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
  .lb-stage { padding: 20px 14px; }
  .lb-nav { width: 40px; height: 40px; font-size: 20px; }
  .crop-body { flex-direction: column; }
  .crop-controls { flex: 1 1 auto; }
  .toolbar { padding: 10px 14px; }
}
