:root {
  --sage-dark: #5F7F62;
  --sage: #82A184;
  --sage-light: #C3D6C2;
  --sage-pale: #EAF1E8;
  --pink: #E3A39A;
  --pink-light: #F6DAD5;
  --pink-pale: #FBEEEB;
  --cream: #FBF8F2;
  --text-dark: #3B4A3B;
  --text-muted: #6E7A6C;
  --white: #FFFFFF;
  --shadow: 0 10px 30px rgba(63, 82, 63, 0.12);
}

/* ---------- Temas seleccionables ---------- */

[data-theme="classic-gold"] {
  --sage-dark: #A8842C;
  --sage: #C9A227;
  --sage-light: #EDE1C0;
  --sage-pale: #FBF8F0;
  --pink: #B08D57;
  --pink-light: #E9DCC0;
  --pink-pale: #FAF6EC;
  --cream: #FFFDF7;
  --text-dark: #4A3F2A;
  --text-muted: #8A7B5C;
  --shadow: 0 10px 30px rgba(90, 74, 30, 0.12);
}

[data-theme="terracotta-boho"] {
  --sage-dark: #A8583D;
  --sage: #C97A5C;
  --sage-light: #E8C3AE;
  --sage-pale: #F7EAE0;
  --pink: #D9A441;
  --pink-light: #F0DDB0;
  --pink-pale: #FBF3E2;
  --cream: #FDF6EE;
  --text-dark: #4A2E22;
  --text-muted: #8C6A57;
  --shadow: 0 10px 30px rgba(90, 50, 30, 0.12);
}

[data-theme="classic-gold"] .eucalyptus-corner {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 140 260'%3E%3Cpath d='M70 260 C 64 200, 78 150, 62 90 C 58 70, 66 50, 60 20' stroke='%23A8842C' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3Cellipse cx='50' cy='225' rx='16' ry='9' fill='%23EDE1C0' transform='rotate(-32 50 225)'/%3E%3Cellipse cx='82' cy='205' rx='16' ry='9' fill='%23C9A227' transform='rotate(28 82 205)'/%3E%3Cellipse cx='48' cy='175' rx='15' ry='8' fill='%23C9A227' transform='rotate(-22 48 175)'/%3E%3Cellipse cx='80' cy='158' rx='15' ry='8' fill='%23A8842C' transform='rotate(22 80 158)'/%3E%3Cellipse cx='46' cy='128' rx='14' ry='8' fill='%23EDE1C0' transform='rotate(-25 46 128)'/%3E%3Cellipse cx='76' cy='112' rx='14' ry='7' fill='%23C9A227' transform='rotate(20 76 112)'/%3E%3Cellipse cx='48' cy='85' rx='13' ry='7' fill='%23A8842C' transform='rotate(-20 48 85)'/%3E%3Cellipse cx='72' cy='68' rx='12' ry='6' fill='%23C9A227' transform='rotate(18 72 68)'/%3E%3Ccircle cx='62' cy='40' r='5' fill='%23B08D57'/%3E%3Ccircle cx='55' cy='30' r='3.5' fill='%23E9DCC0'/%3E%3Ccircle cx='68' cy='24' r='3' fill='%23E9DCC0'/%3E%3C/svg%3E");
}

[data-theme="terracotta-boho"] .eucalyptus-corner {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 140 260'%3E%3Cpath d='M70 260 C 64 200, 78 150, 62 90 C 58 70, 66 50, 60 20' stroke='%23A8583D' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3Cellipse cx='50' cy='225' rx='16' ry='9' fill='%23E8C3AE' transform='rotate(-32 50 225)'/%3E%3Cellipse cx='82' cy='205' rx='16' ry='9' fill='%23C97A5C' transform='rotate(28 82 205)'/%3E%3Cellipse cx='48' cy='175' rx='15' ry='8' fill='%23C97A5C' transform='rotate(-22 48 175)'/%3E%3Cellipse cx='80' cy='158' rx='15' ry='8' fill='%23A8583D' transform='rotate(22 80 158)'/%3E%3Cellipse cx='46' cy='128' rx='14' ry='8' fill='%23E8C3AE' transform='rotate(-25 46 128)'/%3E%3Cellipse cx='76' cy='112' rx='14' ry='7' fill='%23C97A5C' transform='rotate(20 76 112)'/%3E%3Cellipse cx='48' cy='85' rx='13' ry='7' fill='%23A8583D' transform='rotate(-20 48 85)'/%3E%3Cellipse cx='72' cy='68' rx='12' ry='6' fill='%23C97A5C' transform='rotate(18 72 68)'/%3E%3Ccircle cx='62' cy='40' r='5' fill='%23D9A441'/%3E%3Ccircle cx='55' cy='30' r='3.5' fill='%23F0DDB0'/%3E%3Ccircle cx='68' cy='24' r='3' fill='%23F0DDB0'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(180deg, var(--sage-pale) 0%, var(--cream) 320px, var(--cream) 100%);
  color: var(--text-dark);
  min-height: 100vh;
}

h1, h2 {
  font-family: 'Playfair Display', serif;
  margin: 0;
}

/* ---------- Eucalyptus decoration (hand-drawn SVG, no external assets) ---------- */

.eucalyptus-corner {
  position: absolute;
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 140 260'%3E%3Cpath d='M70 260 C 64 200, 78 150, 62 90 C 58 70, 66 50, 60 20' stroke='%235F7F62' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3Cellipse cx='50' cy='225' rx='16' ry='9' fill='%23C3D6C2' transform='rotate(-32 50 225)'/%3E%3Cellipse cx='82' cy='205' rx='16' ry='9' fill='%2382A184' transform='rotate(28 82 205)'/%3E%3Cellipse cx='48' cy='175' rx='15' ry='8' fill='%2382A184' transform='rotate(-22 48 175)'/%3E%3Cellipse cx='80' cy='158' rx='15' ry='8' fill='%235F7F62' transform='rotate(22 80 158)'/%3E%3Cellipse cx='46' cy='128' rx='14' ry='8' fill='%23C3D6C2' transform='rotate(-25 46 128)'/%3E%3Cellipse cx='76' cy='112' rx='14' ry='7' fill='%2382A184' transform='rotate(20 76 112)'/%3E%3Cellipse cx='48' cy='85' rx='13' ry='7' fill='%235F7F62' transform='rotate(-20 48 85)'/%3E%3Cellipse cx='72' cy='68' rx='12' ry='6' fill='%2382A184' transform='rotate(18 72 68)'/%3E%3Ccircle cx='62' cy='40' r='5' fill='%23E3A39A'/%3E%3Ccircle cx='55' cy='30' r='3.5' fill='%23F6DAD5'/%3E%3Ccircle cx='68' cy='24' r='3' fill='%23F6DAD5'/%3E%3C/svg%3E");
  width: 70px;
  height: 130px;
  opacity: 0.85;
}

.eucalyptus-corner--tl { top: -14px; left: -14px; }
.eucalyptus-corner--br { bottom: -14px; right: -14px; transform: rotate(180deg); }

/* ---------- PIN gate ---------- */

.pin-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--sage-pale), var(--pink-pale));
  z-index: 10;
}

.pin-card {
  position: relative;
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 48px 32px 36px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  overflow: hidden;
}

.pin-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: var(--sage-dark);
  margin: 0 0 6px;
}

.script-title {
  font-size: 34px;
  font-style: italic;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 14px;
}

.pin-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 22px;
}

#pinForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#pinInput {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--sage-light);
  font-size: 16px;
  text-align: center;
  background: var(--sage-pale);
  color: var(--text-dark);
}

#pinInput:focus {
  outline: none;
  border-color: var(--sage);
}

.pin-error {
  color: #B4534A;
  font-size: 13px;
  margin-top: 14px;
}

/* ---------- Buttons ---------- */

.btn-primary {
  background: var(--sage-dark);
  color: var(--white);
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.btn-primary:hover:not(:disabled) { background: var(--sage); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { background: var(--sage-light); cursor: not-allowed; }

/* ---------- App layout ---------- */

.app { max-width: 720px; margin: 0 auto; padding: 0 16px 48px; }

.banner {
  position: relative;
  text-align: center;
  padding: 56px 20px 40px;
  overflow: hidden;
}

.banner .eucalyptus-corner { width: 50px; height: 95px; }
.banner .eucalyptus-corner--tl { top: -10px; left: -10px; }
.banner .eucalyptus-corner--br { bottom: 2px; right: -10px; }

.banner-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 12px;
  color: var(--sage-dark);
  margin: 0 0 10px;
}

.banner-title {
  font-size: 32px;
  font-style: italic;
  font-weight: 500;
  color: var(--text-dark);
}

.banner-date {
  margin-top: 10px;
  font-size: 16px;
  letter-spacing: 0.15em;
  color: var(--pink);
  font-weight: 500;
}

.card {
  background: var(--white);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 26px 22px;
  margin-bottom: 24px;
}

.card h2 {
  font-size: 21px;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.section-hint {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0 0 18px;
}

/* ---------- Upload form ---------- */

.upload-form { display: flex; flex-direction: column; gap: 14px; }

.field-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: -6px;
}

#guestName {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--sage-light);
  font-size: 15px;
  font-family: inherit;
  background: var(--sage-pale);
  color: var(--text-dark);
}

#guestName:focus { outline: none; border-color: var(--sage); }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 2px dashed var(--sage-light);
  border-radius: 14px;
  padding: 28px 16px;
  cursor: pointer;
  background: var(--pink-pale);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.dropzone:hover { border-color: var(--pink); }

.dropzone-icon { font-size: 30px; }
.dropzone-text { font-size: 14px; color: var(--text-muted); text-align: center; }

.preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

.preview-list img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--sage-light);
}

.preview-video {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border-radius: 8px;
  background: var(--sage-pale);
  border: 1px solid var(--sage-light);
}

.upload-progress { margin-top: 16px; }

.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 6px;
  background: var(--sage-pale);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--sage-dark);
  transition: width 0.2s ease;
}

#progressText {
  font-size: 13px;
  color: var(--text-muted);
  margin: 6px 0 0;
  text-align: center;
}

.upload-success {
  margin-top: 16px;
  text-align: center;
  color: var(--sage-dark);
  font-size: 14px;
  font-weight: 500;
}

.upload-error {
  margin-top: 16px;
  text-align: center;
  color: #B4534A;
  font-size: 14px;
}

.contribution-counter {
  margin-top: 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
}

/* ---------- Gallery ---------- */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.gallery-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--sage-pale);
  cursor: pointer;
}

.gallery-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(59, 74, 59, 0.55);
  color: var(--white);
  font-size: 13px;
  padding-left: 3px;
}

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

.gallery-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 4px 6px;
  font-size: 10.5px;
  color: var(--white);
  background: linear-gradient(0deg, rgba(59, 74, 59, 0.75), transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

.footer {
  text-align: center;
  color: var(--sage-dark);
  font-size: 13px;
  padding: 20px 0 10px;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(30, 38, 30, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
}

.lightbox-img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 10px;
  object-fit: contain;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 20px;
  background: none;
  border: none;
  color: var(--white);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
}

.lightbox-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.lightbox-caption {
  color: var(--sage-light);
  font-size: 14px;
}

.lightbox-download {
  display: inline-block;
  text-decoration: none;
  padding: 12px 26px;
}

@media (min-width: 600px) {
  .banner-title { font-size: 40px; }
}

/* ---------- Panel de gestion ---------- */

.btn-secondary {
  background: var(--sage-pale);
  color: var(--text-dark);
  border: 1px solid var(--sage-light);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--sage-light); }

.btn-danger {
  background: none;
  border: none;
  color: #B4534A;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
}
.btn-danger:hover { text-decoration: underline; }

.admin-pending-notice {
  background: var(--pink-pale);
  border: 1px solid var(--pink-light);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text-dark);
  margin-bottom: 20px;
}

.admin-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 18px;
}
.admin-stats > div { display: flex; flex-direction: column; }
.admin-stats strong { font-size: 22px; color: var(--sage-dark); font-family: 'Playfair Display', serif; }
.admin-stats span { font-size: 12px; color: var(--text-muted); }

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--sage-pale);
  font-size: 14px;
}
.admin-row:first-of-type { border-top: none; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--text-dark);
}

.theme-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.theme-option {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--sage-light);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  background: var(--sage-pale);
}
.theme-option input { margin: 0; }

.admin-file-list { display: flex; flex-direction: column; }

.admin-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--sage-pale);
}
.admin-file-row:first-child { border-top: none; }

.admin-file-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--sage-pale);
  flex-shrink: 0;
}
.admin-file-thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.admin-file-info { flex: 1; min-width: 0; }
.admin-file-name { font-size: 13.5px; color: var(--text-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-file-meta { font-size: 11.5px; color: var(--text-muted); }

/* ---------- Panel del dueno ---------- */

.owner-app { max-width: 1040px; }

.owner-totals {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.owner-totals > div { display: flex; flex-direction: column; }
.owner-totals strong { font-size: 24px; color: var(--sage-dark); font-family: 'Playfair Display', serif; }
.owner-totals span { font-size: 12px; color: var(--text-muted); }

.owner-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) {
  .owner-form-grid { grid-template-columns: 1fr 1fr; }
  .owner-form-grid .span-2 { grid-column: span 2; }
}
.owner-form-grid input,
.owner-form-grid select {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--sage-light);
  font-size: 14px;
  font-family: inherit;
  background: var(--sage-pale);
  color: var(--text-dark);
  width: 100%;
}

.owner-table-wrap { overflow-x: auto; }
.owner-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 760px; }
.owner-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--sage-light);
  white-space: nowrap;
}
.owner-table td {
  padding: 10px;
  border-bottom: 1px solid var(--sage-pale);
  vertical-align: top;
}
.owner-table td.owner-name { font-weight: 500; color: var(--text-dark); }
.owner-table td.owner-email { color: var(--text-muted); font-size: 12px; }

.status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.status-badge--pending_setup { background: var(--pink-light); color: #7a4a42; }
.status-badge--active { background: var(--sage-light); color: var(--sage-dark); }
.status-badge--past { background: #e4e4e4; color: #666; }

.owner-codes { font-size: 12px; color: var(--text-muted); }
.owner-codes code { background: var(--sage-pale); padding: 2px 5px; border-radius: 5px; }

.owner-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.owner-actions button {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--sage-dark);
  cursor: pointer;
  padding: 2px 0;
}
.owner-actions button:hover { text-decoration: underline; }
.owner-actions button.btn-danger { color: #B4534A; }

/* ---------- Cartel para imprimir ---------- */

.poster-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.poster-controls select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--sage-light);
  background: var(--sage-pale);
  font-size: 13px;
  font-family: inherit;
  color: var(--text-dark);
}

.poster-preview-wrap {
  border: 1px solid var(--sage-light);
  border-radius: 12px;
  padding: 16px;
  overflow: auto;
  background: var(--sage-pale);
  display: flex;
  justify-content: center;
}
.poster-preview-wrap canvas,
.poster-preview-wrap img { max-width: 100%; height: auto; box-shadow: var(--shadow); }

#posterTemplate {
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
}
