:root {
  --cream: #faf6f0;
  --cream-2: #f3ebe0;
  --card: #ffffff;
  --ink: #3a2f2a;
  --muted: #8c7d72;
  --rose: #c98a94;
  --rose-deep: #b0697a;
  --gold: #c9a24b;
  --line: #ece2d5;
  --ok: #4b8a6f;
  --danger: #c05b54;
  --shadow: 0 10px 30px rgba(58, 47, 42, 0.10);
  --shadow-sm: 0 4px 14px rgba(58, 47, 42, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over any `display` rule below
   (.tabs/.btn/.icon-btn set flex/grid, which would otherwise override it). */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -200px, #fff 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, var(--cream) 0%, var(--cream-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
}

.wrap {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 22px 16px 48px;
}

/* ---------- Header ---------- */
.site-header { text-align: center; padding: 14px 0 6px; }
.monogram {
  width: 54px; height: 54px; margin: 0 auto 10px;
  display: grid; place-items: center;
  border: 1.5px solid var(--gold);
  border-radius: 50%;
  color: var(--rose-deep);
}
.monogram svg { width: 26px; height: 26px; display: block; }
.event-name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.9rem, 6vw, 2.7rem);
  line-height: 1.1;
  margin: 4px 0 8px;
  letter-spacing: 0.2px;
}
.event-date {
  text-transform: uppercase;
  letter-spacing: 3px;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
}
.rule {
  width: 64px; height: 1px; margin: 16px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px;
  background: var(--cream-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin: 22px auto 18px;
  max-width: 320px;
}
.tab {
  flex: 1; appearance: none; border: 0; cursor: pointer;
  background: transparent; color: var(--muted);
  font-family: var(--sans); font-size: 0.95rem; font-weight: 600;
  padding: 10px 14px; border-radius: 999px;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.tab[aria-selected="true"] {
  background: var(--card); color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ---------- Cards & panels ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.panel[hidden] { display: none; }
.welcome { color: var(--muted); text-align: center; margin: 0 0 18px; font-size: 0.98rem; }

/* ---------- Form controls ---------- */
label.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: var(--muted); margin-bottom: 6px; letter-spacing: 0.2px;
}
.field-label .opt { font-weight: 400; }
input[type="text"], input[type="password"] {
  width: 100%; font-family: var(--sans); font-size: 16px; color: var(--ink);
  background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 14px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--rose); box-shadow: 0 0 0 3px rgba(201, 138, 148, 0.16);
}

.btn {
  appearance: none; cursor: pointer; font-family: var(--sans);
  font-size: 1rem; font-weight: 600; border-radius: 999px;
  padding: 14px 20px; min-height: 50px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.06s ease, box-shadow 0.18s, background 0.18s, opacity 0.18s;
  width: 100%;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--rose-deep); color: #fff; box-shadow: 0 8px 20px rgba(176, 105, 122, 0.28); }
.btn-primary:hover { background: #a15c6d; }
.btn-ghost { background: var(--cream); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--cream-2); }

/* ---------- Upload dropzone ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; cursor: pointer;
  border: 2px dashed #dfcfc0; border-radius: var(--radius);
  background: linear-gradient(180deg, #fffdfb, var(--cream));
  padding: 30px 18px; margin-bottom: 16px;
  transition: border-color 0.18s, background 0.18s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--rose); background: #fff7f4; }
.dropzone .dz-icon { color: var(--rose-deep); }
.dropzone .dz-icon svg { width: 40px; height: 40px; }
.dropzone .dz-title { font-family: var(--serif); font-size: 1.25rem; }
.dropzone .dz-hint { color: var(--muted); font-size: 0.85rem; }
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- Selected files ---------- */
.queue { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.queue-item {
  display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: center;
  background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px;
}
.thumb {
  width: 54px; height: 54px; border-radius: 9px; object-fit: cover; background: var(--cream-2);
  display: grid; place-items: center; color: var(--muted); overflow: hidden;
}
.thumb svg { width: 22px; height: 22px; }
.qi-main { min-width: 0; }
.qi-name { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qi-sub { font-size: 0.78rem; color: var(--muted); }
.qi-status { font-size: 0.78rem; font-weight: 600; }
.qi-status.ok { color: var(--ok); }
.qi-status.err { color: var(--danger); }
.progress { height: 5px; border-radius: 999px; background: var(--cream-2); overflow: hidden; margin-top: 6px; }
.progress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--rose), var(--gold)); transition: width 0.2s ease; }
.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  cursor: pointer; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--cream-2); color: var(--danger); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Success ---------- */
.success { text-align: center; padding: 8px 0 4px; }
.success .big { font-family: var(--serif); font-size: 1.5rem; margin: 8px 0 4px; }
.success p { color: var(--muted); margin: 0 0 18px; }
.heart-pop { color: var(--rose-deep); }
.heart-pop svg { width: 52px; height: 52px; }

/* ---------- Notices ---------- */
.notice { border-radius: var(--radius-sm); padding: 11px 13px; font-size: 0.88rem; margin-bottom: 14px; }
.notice.err { background: #fbeceb; color: #8f3b37; border: 1px solid #f0cfcd; }
.notice.info { background: #eef4f1; color: #34614f; border: 1px solid #d3e5dc; }
.notice[hidden] { display: none; }

/* ---------- Gallery ---------- */
.gallery-head { display: flex; align-items: baseline; justify-content: space-between; margin: 2px 4px 14px; }
.gallery-count { font-size: 0.85rem; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 480px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 10px; } }
.cell {
  position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--cream-2); border: 0; padding: 0; cursor: pointer; display: block;
}
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s ease; }
.cell:hover img { transform: scale(1.05); }
.cell .badge {
  position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,0.55); color: #fff;
  border-radius: 999px; padding: 3px 8px; font-size: 0.68rem; display: inline-flex; align-items: center; gap: 4px;
}
.cell .badge svg { width: 12px; height: 12px; }
.cell .play {
  position: absolute; inset: 0; display: grid; place-items: center; color: #fff;
  background: linear-gradient(180deg, rgba(0,0,0,0.05), rgba(0,0,0,0.35));
}
.cell .play svg { width: 40px; height: 40px; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4)); }
.gallery-empty { text-align: center; color: var(--muted); padding: 40px 12px; }
.sentinel { height: 1px; }
.loader { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 16px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 50; background: rgba(28, 22, 20, 0.92);
  display: flex; flex-direction: column; padding: 14px; gap: 12px;
}
.lightbox[hidden] { display: none; }
.lb-stage { flex: 1; display: grid; place-items: center; min-height: 0; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.5); }
.lb-bar { display: flex; align-items: center; gap: 10px; color: #f4ece4; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-sub { font-size: 0.76rem; opacity: 0.7; }
.lb-btn {
  appearance: none; border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.08);
  color: #fff; border-radius: 999px; padding: 10px 16px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
}
.lb-btn:hover { background: rgba(255,255,255,0.16); }
.lb-btn svg { width: 17px; height: 17px; }
.lb-close {
  position: absolute; top: 14px; right: 14px; width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,0.12); color: #fff; border: 0; cursor: pointer; display: grid; place-items: center;
}
.lb-close svg { width: 20px; height: 20px; }

/* ---------- Footer ---------- */
.foot { text-align: center; color: var(--muted); font-size: 0.76rem; margin-top: 26px; line-height: 1.7; }
.foot a { color: var(--rose-deep); }

.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.mt { margin-top: 12px; }
.no-scroll { overflow: hidden; }
