:root {
  --bg: #0f1420;
  --bg-card: #171e2e;
  --bg-elevated: #1e2740;
  --text: #e8e6df;
  --muted: #9aa3b5;
  --gold: #c9a24b;
  --gold-soft: #e3c886;
  --error: #e06c6c;
  --ok: #6cc98a;
  --radius: 14px;
}

* { box-sizing: border-box; }
/* The hidden attribute must always win, even over display rules like .btn.wide. */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(201, 162, 75, 0.25);
}
.brand { color: var(--text); text-decoration: none; font-size: 1.2rem; letter-spacing: 0.04em; }
.brand span { color: var(--gold); }
/* Guest-page brand (Lam7a): language spans stay text-colored, the 7 goes gold.
   No intra-word accent on the Arabic mark; splitting joined letters breaks shaping. */
.brand .l-en, .brand .l-ar { color: var(--text); }
.brand b { color: var(--gold); font-weight: inherit; }

.container { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 18px; border-top: 1px solid rgba(255,255,255,0.06); }

.hero { text-align: center; padding: 36px 0 26px; }
.hero.small { padding: 20px 0 10px; }
.hero h1 { font-family: Georgia, "Times New Roman", serif; font-size: 2.2rem; margin: 0 0 12px; }
.hero h1 em { color: var(--gold); font-style: italic; }
.hero .lede { color: var(--muted); max-width: 560px; margin: 0 auto; }

.page-head h1 { font-family: Georgia, serif; margin: 0 0 4px; }

.card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius);
  padding: 24px;
  margin: 18px 0;
}
.card.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.card h2 { margin-top: 0; font-family: Georgia, serif; font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--error); }
code { background: var(--bg-elevated); padding: 2px 7px; border-radius: 6px; font-size: 0.85em; word-break: break-all; }

.form label { display: block; margin-bottom: 14px; font-size: 0.9rem; color: var(--muted); }
.form input[type="text"], .form input[type="password"], .form input[type="date"], .form input[type="file"] {
  display: block; width: 100%; margin-top: 6px;
  background: var(--bg-elevated); color: var(--text);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 8px;
  padding: 10px 12px; font-size: 1rem;
}
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 0.8rem !important; }
.consent input { margin-top: 3px; }

.btn {
  display: inline-block;
  background: var(--gold); color: #14100a;
  border: none; border-radius: 999px;
  padding: 11px 26px; font-size: 1rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--gold-soft); }
.btn:disabled { opacity: 0.6; cursor: wait; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.kv a { color: var(--gold-soft); }

.pill { font-size: 0.75rem; padding: 4px 12px; border-radius: 999px; background: var(--bg-elevated); }
.pill.live { color: var(--ok); }

.qr-box { background: #fff; border-radius: 12px; padding: 14px; width: fit-content; margin: 12px auto; }
.qr-box img { display: block; width: 220px; height: 220px; }

.stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.stat {
  background: var(--bg-elevated); border-radius: 10px;
  padding: 10px 16px; text-align: center; min-width: 84px;
}
.stat b { display: block; font-size: 1.4rem; color: var(--gold-soft); }
.stat span { font-size: 0.75rem; color: var(--muted); }

.dropzone {
  display: block; border: 2px dashed rgba(201,162,75,0.4);
  border-radius: 10px; padding: 26px; text-align: center;
  color: var(--muted); cursor: pointer; transition: border-color 0.15s;
}
.dropzone.over, .dropzone:hover { border-color: var(--gold); color: var(--text); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.photo-grid.large { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.thumb {
  position: relative; display: block; border-radius: 10px; overflow: hidden;
  aspect-ratio: 1; background: var(--bg-elevated);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .badge {
  position: absolute; bottom: 6px; left: 6px;
  font-size: 0.68rem; padding: 2px 8px; border-radius: 999px;
  background: rgba(0,0,0,0.65); color: var(--text);
}
.thumb .badge.pending { color: var(--gold-soft); }
.thumb .badge.failed { color: var(--error); }
.thumb.pop { animation: pop 0.35s ease; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.selfie-preview { margin-bottom: 14px; }
.selfie-preview img { width: 120px; height: 120px; object-fit: cover; border-radius: 50%; border: 2px solid var(--gold); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* Guest pages (body.guest): light theme built from the Lamha logo palette,
   ink #201D1A and gold #B8862B. Operator pages keep the dark theme. */
body.guest {
  --bg: #faf7f2;
  --bg-card: #ffffff;
  --bg-elevated: #f4eee3;
  --text: #201d1a;
  --muted: #857d6f;
  --gold: #b8862b;
  --gold-soft: #8a6420; /* darker in light mode: it's the link/accent color */
  --error: #b3403a;
  --ok: #2e7d4f;
}
body.guest .topbar { background: #fff; border-bottom: 1px solid rgba(184, 134, 43, 0.35); }
body.guest .card { border-color: rgba(32, 29, 26, 0.08); box-shadow: 0 1px 3px rgba(32, 29, 26, 0.06); }
body.guest .footer { border-top-color: rgba(32, 29, 26, 0.08); }
body.guest .form input[type="text"], body.guest .form input[type="file"] {
  background: #fff; border-color: rgba(32, 29, 26, 0.18);
}
body.guest .btn.secondary { background: #efe8db; color: var(--text); }
body.guest .btn.secondary:hover { background: #e5dccb; }
body.guest .pill { background: #f1ebde; }
body.guest .thumb { background: #ede6d8; }
body.guest .sheet-backdrop { background: rgba(32, 29, 26, 0.45); }
body.guest .lang-pill, body.guest .save-pill { color: var(--gold-soft); }
.brand-logo { display: block; height: 26px; width: auto; }

/* Guest pages are single-language with a switcher (#lang-toggle in the
   header). body.lang-ar shows Arabic strings and flips direction. */
.l-ar { display: none; }
body.lang-ar .l-ar { display: inline; }
body.lang-ar .l-en { display: none; }
body.lang-ar { direction: rtl; }
.lang-pill { cursor: pointer; border: none; font: inherit; font-size: 0.75rem; color: var(--text); }

/* Selfie preview is mirrored like the camera's live view (guests expect the
   mirror image of themselves). Display only; the stored selfie is untouched. */
.selfie-preview img { transform: scaleX(-1); }

.btn.wide { display: block; width: 100%; text-align: center; margin: 10px 0; }
.btn.secondary { background: var(--bg-elevated); color: var(--text); }
.btn.secondary:hover { background: #2a3550; }
.btn-plain {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 0.9rem; text-decoration: underline;
  display: block; margin: 6px auto 0;
}

.consent-details { margin: 12px 0; font-size: 0.85rem; color: var(--muted); }
.consent-details summary { cursor: pointer; color: var(--text); margin-bottom: 8px; }
.consent-details ul { padding-inline-start: 20px; }
.consent-details li { margin-bottom: 6px; }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 8, 16, 0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.sheet-backdrop[hidden] { display: none; }
.sheet { margin: 0; max-height: 90vh; overflow-y: auto; }
.gallery-link { margin: 8px 0; }
.gallery-link a { color: var(--gold-soft); word-break: break-all; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.btn.small { padding: 8px 18px; font-size: 0.9rem; }
.thumb.selected img { opacity: 0.55; }
.thumb.selected::after {
  content: '✓'; position: absolute; top: 6px; inset-inline-end: 6px;
  width: 24px; height: 24px; border-radius: 999px;
  background: var(--gold); color: #14100a;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700;
}
.save-pill { cursor: pointer; border: none; color: var(--gold-soft); font: inherit; font-size: 0.75rem; }
