/* ---------- Theme ----------
   Swap these to match the wedding colours. Everything else reads from them. */
:root {
  --bg: #f7f3ec;
  --bg-glow: #fdfbf7;
  --surface: #fffdf9;
  --ink: #2b2723;
  --muted: #776d64;
  --line: #e6ddd0;
  --accent: #5f7052;        /* sage */
  --on-accent: #ffffff;
  --accent-soft: #e7ebdf;
  --gold: #a88450;
  --danger: #b0503a;
  --shadow: 0 1px 2px rgb(60 45 30 / 0.05), 0 8px 24px rgb(60 45 30 / 0.07);

  --font-display: "Cormorant Garamond", "Times New Roman", serif;
  --font-body: "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1815;
    --bg-glow: #221f1b;
    --surface: #25221e;
    --ink: #f1ebe2;
    --muted: #a99f93;
    --line: #3a352f;
    --accent: #a3b38f;
    --on-accent: #1a1815;
    --accent-soft: #2f3529;
    --gold: #cfae78;
    --danger: #e0826b;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(120% 60% at 50% 0%, var(--bg-glow), var(--bg) 70%) fixed, var(--bg);
  color: var(--ink);
  font: 400 17px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
img, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.page {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.page-wide { max-width: 1200px; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 20px 0 28px; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 12px; font-weight: 500; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--muted);
}
.names {
  margin: 0;
  font: 500 clamp(2.9rem, 13vw, 4.6rem)/1 var(--font-display);
  letter-spacing: -0.01em;
}
.amp { font-style: italic; color: var(--gold); padding: 0 0.04em; }
.date { margin: 12px 0 0; color: var(--muted); font-size: 15px; letter-spacing: 0.04em; }
.flourish {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 18px auto 0; color: var(--gold); width: 180px;
}
.flourish::before, .flourish::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: 0.5; }

/* ---------- Cards & type ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
}
.card + .card, .card + .queue, .queue + .card { margin-top: 16px; }
h2 {
  margin: 0 0 6px;
  font: 600 1.7rem/1.15 var(--font-display);
}
.lede { margin: 0 0 20px; color: var(--muted); }
.hint { margin: 16px 0 0; font-size: 14px; color: var(--muted); text-align: center; }

/* ---------- Form bits ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.field em { font-style: normal; color: var(--muted); font-weight: 400; }
input[type="text"], input[type="password"], input[type="number"], input[type="url"] {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-glow);
  color: var(--ink);
  font: inherit;
  font-size: 17px; /* ≥16px stops iOS zooming on focus */
}
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 999px;
  font-weight: 500; font-size: 16px; text-decoration: none;
  cursor: pointer; user-select: none;
  transition: transform 0.12s ease, background-color 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-soft { background: var(--accent-soft); color: var(--ink); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-big { width: 100%; min-height: 58px; font-size: 18px; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 20px; }

.turnstile:not(:empty) { display: flex; justify-content: center; margin-top: 14px; }

/* ---------- Upload queue ---------- */
.queue { margin-top: 16px; }
.queue-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.queue-head h2 { font-size: 1.4rem; margin: 0; }
.queue-head p { margin: 0; color: var(--muted); font-size: 14px; white-space: nowrap; }
.bar { height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 0.3s ease; }
.queue .overall { margin: 12px 0 14px; }
.queue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.q-item {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 12px;
  padding: 8px 10px 8px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.q-thumb {
  width: 52px; height: 52px; border-radius: 10px; overflow: hidden;
  background: var(--accent-soft); display: grid; place-items: center; color: var(--muted);
}
.q-thumb img { width: 100%; height: 100%; object-fit: cover; }
.q-thumb svg { width: 22px; height: 22px; }
.q-main { min-width: 0; }
.q-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-status { font-size: 13px; color: var(--muted); margin-top: 2px; }
.q-item .bar { height: 4px; margin-top: 6px; }
.q-item.is-done .bar, .q-item.is-error .bar { display: none; }
.q-item.is-done .q-status { color: var(--accent); }
.q-item.is-error .q-status { color: var(--danger); }
.q-action {
  border: 0; background: none; padding: 8px; margin: -8px -4px -8px 0; border-radius: 999px;
  color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.queue-done {
  margin: 16px 0 0; padding: 16px; text-align: center;
  background: var(--accent-soft); border-radius: 14px;
}
.queue-done strong { display: block; font: 600 1.35rem/1.2 var(--font-display); margin-bottom: 4px; }

/* ---------- Gallery ---------- */
.top-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 20px;
}
.top-bar h1 { margin: 0; font: 500 clamp(1.9rem, 7vw, 2.6rem)/1.05 var(--font-display); }
.top-bar .count { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 4px;
  border-radius: 12px;
  overflow: hidden;
}
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; } }
.tile {
  position: relative; aspect-ratio: 1; padding: 0; border: 0; margin: 0;
  background: var(--accent-soft); cursor: pointer; overflow: hidden;
}
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease, opacity 0.4s ease; opacity: 0; }
.tile img.loaded { opacity: 1; }
@media (hover: hover) { .tile:hover img { transform: scale(1.03); } }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.tile .placeholder svg { width: 28px; height: 28px; }
.tile .badge {
  position: absolute; left: 6px; bottom: 6px;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px 2px 5px; border-radius: 999px;
  background: rgb(0 0 0 / 0.55); color: #fff; font-size: 12px; font-weight: 500;
}
.tile .badge svg { width: 12px; height: 12px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h2 { color: var(--ink); }
.loader { display: flex; justify-content: center; padding: 28px; color: var(--muted); font-size: 14px; }
.new-pill {
  position: fixed; left: 50%; top: max(14px, env(safe-area-inset-top)); transform: translateX(-50%);
  z-index: 20; box-shadow: var(--shadow);
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgb(14 12 10 / 0.96); color: #f4efe7;
  display: grid; grid-template-rows: auto 1fr auto;
  touch-action: pan-y;
}
.lb-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
}
.lb-bar .lb-count { font-size: 14px; opacity: 0.7; }
.lb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; height: 44px; padding: 0 12px;
  border: 0; border-radius: 999px; background: rgb(255 255 255 / 0.1); color: inherit;
  cursor: pointer; text-decoration: none; font-size: 15px;
}
.lb-btn svg { width: 20px; height: 20px; }
.lb-stage { position: relative; min-height: 0; overflow: hidden; }
.lb-stage .lb-media {
  position: absolute; top: 0; left: 8px; width: calc(100% - 16px); height: 100%;
  max-width: none; object-fit: contain;
}
.lb-stage .lb-fallback { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lb-stage .lb-fallback { text-align: center; padding: 24px; color: #f4efe7; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 999px; border: 0;
  background: rgb(255 255 255 / 0.1); color: inherit; cursor: pointer;
  display: none; place-items: center;
}
.lb-nav svg { width: 24px; height: 24px; }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
@media (hover: hover) and (min-width: 700px) { .lb-nav { display: grid; } }
.lb-caption {
  text-align: center; font-size: 14px; opacity: 0.75;
  padding: 12px 16px max(16px, env(safe-area-inset-bottom));
}

/* ---------- Admin ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat b { display: block; font: 600 1.8rem/1.1 var(--font-display); }
.stat span { font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs .btn { min-height: 38px; padding: 0 16px; font-size: 15px; }
.tabs .btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.admin-tile { position: relative; }
.admin-tile.is-hidden .tile img { opacity: 0.3; }
.admin-tile .tools {
  position: absolute; right: 6px; top: 6px; display: flex; gap: 4px;
}
.admin-tile .tools button {
  height: 32px; padding: 0 10px; border: 0; border-radius: 999px; cursor: pointer;
  background: rgb(0 0 0 / 0.6); color: #fff; font-size: 12px; font-weight: 500;
}
.admin-tile .tools button.danger { background: rgb(160 50 30 / 0.85); }
.admin-tile .hidden-tag {
  position: absolute; left: 6px; top: 6px; padding: 2px 8px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
}
.admin-tile .meta {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.65)); color: #fff; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.section-title { margin: 36px 0 12px; }

/* ---------- Printable table cards ---------- */
.card-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card-controls .field:first-child { grid-column: 1 / -1; }
.table-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; }
.table-card {
  background: #fffdf9; color: #2b2723;
  border: 1px solid #e6ddd0; border-radius: 12px;
  padding: 22px 18px 18px; text-align: center;
  break-inside: avoid;
}
.table-card .tc-names { font: 500 1.9rem/1 var(--font-display); }
.table-card .tc-names i { color: #a88450; }
.table-card .tc-table { margin-top: 6px; font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: #776d64; }
.table-card svg { width: 70%; height: auto; margin: 14px auto; display: block; }
.table-card .tc-cta { font: 600 1.15rem/1.2 var(--font-display); }
.table-card .tc-url { margin-top: 4px; font-size: 12px; color: #776d64; word-break: break-all; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .page { max-width: none; padding: 0; }
  .table-cards { grid-template-columns: repeat(2, 1fr); gap: 10mm; }
  .table-card { border-color: #ccc; }
}

/* Late additions */
.q-item.is-cancelled { opacity: 0.55; }
.q-item.is-cancelled .bar { display: none; }
#album-preview { grid-template-columns: repeat(3, 1fr); }
