:root {
  --wine: #29473d;
  --wine-dark: #17352c;
  --berry: #536f63;
  --pearl: #f5f0e7;
  --paper: #fffdf8;
  --ink: #24332e;
  --muted: #6e756f;
  --line: #dcd4c6;
  --gold: #aa8b53;
  --success: #276341;
  --danger: #9c3740;
  --shadow: 0 28px 80px rgba(34, 55, 47, 0.13);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--pearl); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.guest-page {
  background:
    radial-gradient(circle at 8% 12%, rgba(83, 111, 99, 0.12), transparent 28rem),
    radial-gradient(circle at 92% 88%, rgba(170, 139, 83, 0.13), transparent 26rem),
    linear-gradient(145deg, #ece5d9, #f8f4ed 46%, #eee7dc);
}

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.upload-card {
  position: relative;
  width: min(100%, 620px);
  padding: 42px clamp(22px, 6vw, 58px) 30px;
  overflow: hidden;
  border: 1px solid rgba(170, 139, 83, 0.38);
  border-radius: 3px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: var(--shadow);
  text-align: center;
}

.upload-card::before,
.upload-card::after {
  content: '';
  position: absolute;
  width: 120px;
  height: 120px;
  border: 1px solid rgba(170, 139, 83, 0.25);
  transform: rotate(45deg);
  pointer-events: none;
}

.upload-card::before { top: -94px; left: -64px; }
.upload-card::after { right: -64px; bottom: -94px; }

.wedding-logo {
  width: min(230px, 56vw);
  height: auto;
  display: block;
  margin: -4px auto 18px;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--berry);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.28em;
}

h1, h2 {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 400;
}

h1 {
  margin: 0;
  color: var(--wine-dark);
  font-size: clamp(2.45rem, 12vw, 4.7rem);
  font-style: italic;
  line-height: 1;
  letter-spacing: -0.015em;
}

.wedding-date {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  margin: 19px 0 0;
  color: var(--gold);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
}

.wedding-date span {
  width: 42px;
  height: 1px;
  background: rgba(170, 139, 83, 0.52);
}

.intro {
  max-width: 390px;
  margin: 19px auto 31px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

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

.field label {
  display: flex;
  justify-content: space-between;
  margin: 0 0 7px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
}

.field label span { color: var(--muted); font-size: 0.8rem; font-weight: 400; }

.field input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: none;
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input:focus {
  border-color: var(--berry);
  box-shadow: 0 0 0 4px rgba(83, 111, 99, 0.11);
}

.picker {
  width: 100%;
  min-height: 166px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 22px;
  border: 1.5px dashed rgba(83, 111, 99, 0.48);
  border-radius: 3px;
  background: rgba(83, 111, 99, 0.035);
  color: var(--wine);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.picker:hover, .picker:focus-visible, .picker.is-dragging {
  border-color: var(--berry);
  background: rgba(83, 111, 99, 0.075);
  transform: translateY(-1px);
}

.picker-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin-bottom: 3px;
  border-radius: 2px;
  background: var(--wine);
  color: #fff;
}

.picker-icon svg { width: 23px; fill: currentColor; }
.picker strong { font-size: 1rem; }
.picker small { color: var(--muted); font-size: 0.85rem; }

.selection {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255,255,255,0.7);
}

.selection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  text-align: left;
}

.selection-head strong { font-size: 0.92rem; }

.text-button {
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--berry);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.preview-item {
  position: relative;
  aspect-ratio: 1;
  overflow: visible;
  border-radius: 10px;
  background: #e8e5dc;
}

.preview-item img,
.preview-fallback {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: cover;
}

.preview-fallback {
  display: grid;
  place-items: center;
  color: var(--berry);
  font-size: 0.72rem;
  font-weight: 700;
}

.remove-photo {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  padding: 0 0 2px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--wine-dark);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 54px;
  margin-top: 16px;
  border-radius: 2px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.primary-button {
  border: 0;
  background: linear-gradient(135deg, var(--berry), var(--wine-dark));
  color: #fff;
  box-shadow: 0 12px 25px rgba(87, 29, 49, 0.22);
}

.primary-button:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 14px 29px rgba(87,29,49,0.29); }
.primary-button:disabled { cursor: not-allowed; opacity: 0.42; box-shadow: none; }

.secondary-button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--wine);
}

.form-message { margin: 13px 0 0; font-size: 0.9rem; line-height: 1.45; }
.form-message.error { color: var(--danger); }

.progress-panel { margin-top: 18px; text-align: left; }
.progress-copy { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 0.88rem; font-weight: 600; }
.progress-track { height: 9px; overflow: hidden; border-radius: 999px; background: #eadfe2; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--berry), var(--gold)); transition: width 120ms linear; }
.progress-panel p { margin: 8px 0 0; color: var(--muted); font-size: 0.8rem; }

.success-panel { padding: 18px 0 8px; }
.success-mark { width: 68px; height: 68px; display: grid; place-items: center; margin: 8px auto 18px; border-radius: 50%; background: rgba(39, 99, 65, 0.11); color: var(--success); font-size: 31px; font-weight: 700; }
.success-panel h2 { margin: 0; color: var(--wine-dark); font-size: 2.4rem; }
.success-panel p { color: var(--muted); line-height: 1.55; }

.optimization-note { margin: 18px auto 0; color: var(--berry); font-size: 0.76rem; line-height: 1.45; }
.privacy-note { margin: 7px auto 0; color: var(--muted); font-size: 0.74rem; line-height: 1.45; }

/* Admin */
.admin-page { min-height: 100vh; background: #f2eee6; }
.admin-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 70px; }
.admin-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.admin-header .eyebrow { margin-bottom: 5px; }
.admin-header h1 { font-size: clamp(2rem, 7vw, 3.5rem); }
.admin-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.admin-button { min-height: 43px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--wine); font-size: 0.88rem; font-weight: 700; text-decoration: none; cursor: pointer; }
.admin-button.primary { border-color: var(--wine); background: var(--wine); color: white; }
.stats { display: flex; gap: 12px; margin-bottom: 22px; }
.stat { min-width: 150px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.stat strong { display: block; color: var(--wine); font-size: 1.45rem; }
.stat span { color: var(--muted); font-size: 0.8rem; }
.admin-notice { margin: 0 0 18px; padding: 12px 14px; border: 1px solid #efc0c5; border-radius: 10px; background: #fff5f6; color: #842733; }
.gallery-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.gallery-item { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 8px 28px rgba(53,16,31,0.06); }
.gallery-media { aspect-ratio: 1; overflow: hidden; background: #ece4e6; }
.gallery-media img { width: 100%; height: 100%; display: block; object-fit: cover; }
.gallery-fallback { height: 100%; display: grid; place-items: center; color: var(--berry); font-size: 1rem; font-weight: 700; }
.gallery-info { padding: 13px; }
.gallery-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.88rem; }
.gallery-info p { margin: 5px 0 12px; color: var(--muted); font-size: 0.75rem; line-height: 1.45; }
.gallery-buttons { display: flex; gap: 7px; }
.gallery-buttons .admin-button { min-height: 36px; flex: 1; padding: 7px; font-size: 0.76rem; }
.delete-button { border-color: #efc6cc; color: var(--danger); }
.empty-state { padding: 60px 24px; border: 1px dashed #d8c7cb; border-radius: 18px; background: rgba(255,255,255,0.65); text-align: center; }
.empty-state h2 { margin: 0 0 7px; font-size: 2rem; }
.empty-state p { margin: 0; color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 24px; }
.pagination span { color: var(--muted); font-size: 0.88rem; }
.login-card { width: min(100%, 430px); margin: 12vh auto 0; padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: white; box-shadow: var(--shadow); }
.login-card h1 { margin-bottom: 8px; font-size: 2.8rem; }
.login-card > p { margin: 0 0 22px; color: var(--muted); }

@media (max-width: 820px) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .page-shell { padding-left: 10px; padding-right: 10px; }
  .upload-card { padding: 24px 18px 23px; border-radius: 23px; }
  .wedding-logo { width: min(190px, 58vw); margin-bottom: 14px; }
  .preview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-header { align-items: flex-start; flex-direction: column; }
  .admin-actions { justify-content: flex-start; }
  .stats { flex-wrap: wrap; }
  .stat { flex: 1; min-width: 130px; }
  .gallery-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
