/* ============================================================================
   OAKEN MOMENTS — Design System
   Warm editorial. Built for 60+ guests on slow Nigerian mobile connections.

   HARD RULES baked into this file:
     - Base font size is 18px. Nothing user-facing is below 15px.
     - Every interactive target is >= 56px tall (inputs 60px).
     - Focus is always visible, 3px, never removed.
     - No web fonts. System stacks only, so first paint needs zero network.
     - No images in CSS. Total weight target < 20KB gzipped.
     - Colour contrast >= 4.5:1 for text, >= 3:1 for UI boundaries.
   ============================================================================ */

/* ---------------------------------------------------------------- 1. TOKENS */

:root {
  /* --- Warm editorial palette (light) --- */
  --paper:        #FBF7F0;   /* page ground, warm ivory */
  --surface:      #FFFFFF;   /* cards, sheets */
  --surface-2:    #F4EDE2;   /* subtle fills, table stripes */
  --surface-3:    #EBE1D2;   /* pressed / hover fills */
  --line:         #E0D5C4;   /* hairlines */
  --line-strong:  #C9BAA3;   /* input borders, needs 3:1 */

  --ink:          #211D18;   /* primary text — 14.8:1 on paper */
  --ink-2:        #4C443A;   /* secondary text — 8.1:1 */
  --ink-3:        #6E6357;   /* muted / meta — 5.1:1 */

  --accent:       #A94A24;   /* terracotta — 5.9:1 on paper */
  --accent-deep:  #82361A;   /* pressed */
  --accent-soft:  #F7E8DF;   /* tint fill */
  --accent-line:  #E5C6B4;

  --gold:         #8A6A1F;   /* secondary accent — 5.2:1 */
  --gold-soft:    #F6EEDA;

  --ok:           #2C6644;
  --ok-soft:      #E4F0E7;
  --warn:         #7E5A0E;
  --warn-soft:    #FAF0D9;
  --danger:       #9C2A21;
  --danger-soft:  #FBE6E3;
  --info:         #2A5570;
  --info-soft:    #E5EEF4;

  /* --- Type --- */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino,
                  "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-body:    system-ui, -apple-system, "Segoe UI", Roboto,
                  "Helvetica Neue", Arial, sans-serif;
  --font-mono:    ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --fs-xs:   0.833rem;  /* 15px — meta only, never body copy */
  --fs-sm:   0.944rem;  /* 17px */
  --fs-base: 1rem;      /* 18px */
  --fs-md:   1.111rem;  /* 20px */
  --fs-lg:   1.333rem;  /* 24px */
  --fs-xl:   1.722rem;  /* 31px */
  --fs-2xl:  2.222rem;  /* 40px */
  --fs-3xl:  2.889rem;  /* 52px */

  /* --- Space (4px base) --- */
  --s1: 4px;   --s2: 8px;   --s3: 12px;  --s4: 16px;
  --s5: 20px;  --s6: 24px;  --s7: 32px;  --s8: 40px;
  --s9: 56px;  --s10: 72px;

  /* --- Shape --- */
  --r-sm: 6px;  --r-md: 10px;  --r-lg: 16px;  --r-xl: 24px;  --r-pill: 999px;

  /* --- Elevation. Warm shadows, never grey. --- */
  --sh-1: 0 1px 2px rgba(51,38,24,.06), 0 1px 3px rgba(51,38,24,.05);
  --sh-2: 0 2px 6px rgba(51,38,24,.07), 0 6px 16px rgba(51,38,24,.06);
  --sh-3: 0 8px 20px rgba(51,38,24,.10), 0 20px 40px rgba(51,38,24,.08);

  /* --- Ergonomics for 60+ --- */
  --tap:     56px;   /* minimum interactive height */
  --tap-lg:  64px;   /* primary actions */
  --input-h: 60px;

  --dur: 180ms;
  --ease: cubic-bezier(.2,.7,.3,1);

  /* --- Per-event branding hooks. Server rewrites ONLY these four. --- */
  --brand:        var(--accent);
  --brand-deep:   var(--accent-deep);
  --brand-soft:   var(--accent-soft);
  --brand-on:     #FFFFFF;  /* text colour that sits on --brand */
}

/* Dark: gallery, lightbox and Live Wall. Photos read better on dark ground. */
[data-theme="dark"] {
  --paper:        #16130F;
  --surface:      #201C17;
  --surface-2:    #2A251E;
  --surface-3:    #352E25;
  --line:         #372F26;
  --line-strong:  #554B3E;

  --ink:          #F6F0E6;
  --ink-2:        #D3C8B8;
  --ink-3:        #A2957F;

  --accent:       #E8845A;
  --accent-deep:  #F2A181;
  --accent-soft:  #33231A;
  --accent-line:  #4E362A;

  --gold:         #D4AE5E;
  --gold-soft:    #302716;

  --ok:      #7CC79A;  --ok-soft:     #1B2E22;
  --warn:    #E0BB63;  --warn-soft:   #2E2714;
  --danger:  #F09287;  --danger-soft: #331B18;
  --info:    #8FBBD9;  --info-soft:   #16262F;

  --brand-on: #1A1310;
  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 2px 8px rgba(0,0,0,.45);
  --sh-3: 0 10px 30px rgba(0,0,0,.55);
}

/* -------------------------------------------------------------- 2. RESET */

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 18px;              /* the 60+ decision, stated once */
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

img, svg, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
h1,h2,h3,h4,p,figure,ul,ol { margin: 0; }
ul,ol { padding: 0; list-style: none; }
a { color: var(--brand); text-underline-offset: 3px; }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--brand-soft); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------- 3. TYPOGRAPHY */

.m-display  { font-family: var(--font-display); font-weight: 600; line-height: 1.15;
              letter-spacing: -.015em; }
.m-h1 { font-size: var(--fs-2xl); }
.m-h2 { font-size: var(--fs-xl); }
.m-h3 { font-size: var(--fs-lg); }
.m-h4 { font-size: var(--fs-md); font-family: var(--font-body); font-weight: 650; }

.m-lead    { font-size: var(--fs-md); color: var(--ink-2); line-height: 1.55; }
.m-muted   { color: var(--ink-3); }
.m-meta    { font-size: var(--fs-xs); color: var(--ink-3); letter-spacing: .01em; }
.m-eyebrow { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .12em;
             text-transform: uppercase; color: var(--ink-3); }
.m-num     { font-family: var(--font-display); font-variant-numeric: tabular-nums;
             font-weight: 600; letter-spacing: -.02em; }
.m-mono    { font-family: var(--font-mono); font-size: var(--fs-sm); }

/* Hairline rule with an optional centred label */
.m-rule { border: 0; border-top: 1px solid var(--line); margin: var(--s6) 0; }

/* ------------------------------------------------------------- 4. LAYOUT */

.m-shell   { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.m-wrap    { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 var(--s5); }
.m-wrap--narrow { max-width: 560px; }
.m-wrap--reading { max-width: 720px; }
.m-main    { flex: 1; padding-block: var(--s6) var(--s10); }

.m-stack > * + * { margin-top: var(--s4); }
.m-stack-lg > * + * { margin-top: var(--s7); }
.m-row     { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.m-row--tight { gap: var(--s2); }
.m-row--between { justify-content: space-between; }
.m-spacer  { flex: 1; }

.m-cols    { display: grid; gap: var(--s5); }
.m-cols-2  { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.m-cols-3  { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.m-cols-4  { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* Guest screens leave room for the bottom nav + iOS home indicator */
.m-main--guest { padding-bottom: calc(var(--s10) + var(--tap) + env(safe-area-inset-bottom)); }

/* --------------------------------------------------------------- 5. CARD */

.m-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.m-card__hd {
  padding: var(--s5) var(--s5) var(--s4);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
}
.m-card__bd { padding: var(--s5); }
.m-card__ft {
  padding: var(--s4) var(--s5);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.m-card--flat  { box-shadow: none; }
.m-card--quiet { background: var(--surface-2); border-color: transparent; box-shadow: none; }

/* ------------------------------------------------------------ 6. BUTTONS */

.m-btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s5);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1.5px solid var(--btn-bd);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.m-btn:hover  { background: var(--surface-3); }
.m-btn:active { transform: translateY(1px); }
.m-btn[disabled], .m-btn[aria-disabled="true"] {
  opacity: .5; cursor: not-allowed; transform: none;
}

.m-btn--primary {
  --btn-bg: var(--brand); --btn-fg: var(--brand-on); --btn-bd: var(--brand);
  box-shadow: var(--sh-1);
}
.m-btn--primary:hover { --btn-bg: var(--brand-deep); --btn-bd: var(--brand-deep); }

.m-btn--ghost  { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--brand); }
.m-btn--ghost:hover { background: var(--brand-soft); }

.m-btn--danger { --btn-bg: var(--surface); --btn-fg: var(--danger); --btn-bd: var(--danger); }
.m-btn--danger:hover { background: var(--danger-soft); }

/* The single most important button in the product: "Add your photos". */
.m-btn--hero {
  min-height: var(--tap-lg);
  font-size: var(--fs-md);
  padding: 0 var(--s7);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.m-btn--block { display: flex; width: 100%; }
.m-btn--sm    { min-height: 44px; padding: 0 var(--s4); font-size: var(--fs-sm); }
/* --sm is admin-desktop only. Never put it on a guest screen. */

.m-btn__ic { font-size: 1.2em; line-height: 1; }

/* Icon-only control. Still 56px, still labelled via aria-label. */
.m-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap);
  background: transparent; border: 0; border-radius: var(--r-md);
  color: var(--ink-2); font-size: var(--fs-lg); cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.m-iconbtn:hover { background: var(--surface-3); color: var(--ink); }

/* --------------------------------------------------------------- 7. FORM */

.m-field { display: block; }
.m-field + .m-field { margin-top: var(--s5); }

.m-label {
  display: block; margin-bottom: var(--s2);
  font-size: var(--fs-base); font-weight: 650; color: var(--ink);
}
.m-hint  { display: block; margin-top: var(--s2); font-size: var(--fs-sm); color: var(--ink-3); }
.m-error { display: block; margin-top: var(--s2); font-size: var(--fs-sm);
           color: var(--danger); font-weight: 600; }

.m-input, .m-select, .m-textarea {
  width: 100%;
  min-height: var(--input-h);
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  font-size: var(--fs-md);        /* 20px — >=16px also stops iOS zoom-on-focus */
  color: var(--ink);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.m-textarea { min-height: 130px; padding: var(--s4); line-height: 1.55; resize: vertical; }
.m-input:focus, .m-select:focus, .m-textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.m-input::placeholder, .m-textarea::placeholder { color: var(--ink-3); opacity: 1; }
.m-input[aria-invalid="true"] { border-color: var(--danger); }

.m-select {
  appearance: none;
  padding-right: var(--s8);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 22px) 55%, calc(100% - 14px) 55%;
  background-size: 8px 8px, 8px 8px;
  background-repeat: no-repeat;
}

/* Whole-row checkbox. The label IS the target, so it is trivially tappable. */
.m-check {
  display: flex; align-items: flex-start; gap: var(--s3);
  min-height: var(--tap);
  padding: var(--s3) var(--s4);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.m-check:hover { border-color: var(--line-strong); background: var(--surface-2); }
.m-check:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.m-check input { width: 26px; height: 26px; margin: 3px 0 0; accent-color: var(--brand);
                 flex: none; cursor: pointer; }
.m-check__txt { font-size: var(--fs-sm); line-height: 1.5; }
.m-check--on { border-color: var(--brand); background: var(--brand-soft); }

/* Segmented switch — used for theme, layout, moderation mode */
.m-seg { display: inline-flex; padding: 4px; gap: 4px;
         background: var(--surface-2); border: 1px solid var(--line);
         border-radius: var(--r-md); }
.m-seg__btn { min-height: 48px; padding: 0 var(--s4); border: 0; border-radius: var(--r-sm);
              background: transparent; color: var(--ink-2); font-weight: 600;
              font-size: var(--fs-sm); cursor: pointer; }
.m-seg__btn[aria-pressed="true"] { background: var(--surface); color: var(--ink);
                                   box-shadow: var(--sh-1); }

/* Colour token picker (event branding) */
.m-swatch { width: var(--tap); height: var(--tap); padding: 0; border-radius: var(--r-md);
            border: 1.5px solid var(--line-strong); cursor: pointer; }

/* -------------------------------------------------------------- 8. BADGE */

.m-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px var(--s3);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.m-badge--ok      { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.m-badge--warn    { background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.m-badge--danger  { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.m-badge--info    { background: var(--info-soft);   color: var(--info);   border-color: transparent; }
.m-badge--brand   { background: var(--brand-soft);  color: var(--brand-deep); border-color: transparent; }
.m-badge__dot     { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

.m-pill-count { display: inline-flex; align-items: center; justify-content: center;
                min-width: 26px; height: 26px; padding: 0 7px; border-radius: var(--r-pill);
                background: var(--danger); color: #fff; font-size: var(--fs-xs);
                font-weight: 700; }

/* ------------------------------------------------------------- 9. TOPBAR */

.m-topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.m-topbar__in { display: flex; align-items: center; gap: var(--s3);
                min-height: var(--tap); padding: var(--s2) var(--s4); }
.m-topbar__title { font-family: var(--font-display); font-size: var(--fs-md);
                   font-weight: 600; line-height: 1.2; }
.m-topbar__sub   { font-size: var(--fs-xs); color: var(--ink-3); }

.m-brandmark { display: flex; align-items: center; gap: var(--s2);
               font-family: var(--font-display); font-weight: 600;
               font-size: var(--fs-md); color: var(--ink); text-decoration: none; }
.m-brandmark__mark { width: 38px; height: 38px; border-radius: 50%;
                     background: var(--brand); color: var(--brand-on);
                     display: grid; place-items: center; font-size: var(--fs-sm);
                     font-weight: 700; flex: none; }

/* --------------------------------------------------------- 10. BOTTOM NAV */
/* Guest only. Four items max — five is already too many for this audience. */

.m-bottomnav {
  position: fixed; inset: auto 0 0 0; z-index: 45;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(51,38,24,.06);
}
.m-bottomnav__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: var(--tap); padding: var(--s2) var(--s1);
  color: var(--ink-3); text-decoration: none;
  font-size: var(--fs-xs); font-weight: 600;
  border-top: 3px solid transparent; margin-top: -1px;
}
.m-bottomnav__item[aria-current="page"] { color: var(--brand); border-top-color: var(--brand); }
.m-bottomnav__ic { font-size: 22px; line-height: 1; }

/* FAB sits above the bottom nav, never over content the guest is reading. */
.m-fab {
  position: fixed; right: var(--s5); z-index: 46;
  bottom: calc(var(--tap) + var(--s5) + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: var(--s2);
  height: var(--tap-lg); padding: 0 var(--s6);
  background: var(--brand); color: var(--brand-on);
  border: 0; border-radius: var(--r-pill);
  font-size: var(--fs-base); font-weight: 700;
  box-shadow: var(--sh-3); cursor: pointer;
  text-decoration: none;
}
.m-fab:active { transform: translateY(1px); }

/* ------------------------------------------------------------ 11. SIDEBAR */
/* Admin + super admin only. Collapses to the topbar drawer under 900px. */

.m-admin { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.m-side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: var(--s5) var(--s4);
  display: flex; flex-direction: column; gap: var(--s6);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.m-side__group { display: flex; flex-direction: column; gap: 2px; }
.m-side__lbl { padding: 0 var(--s3) var(--s2); font-size: var(--fs-xs);
               font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
               color: var(--ink-3); }
.m-side__switch { margin: 0 var(--s3) var(--s3); width: calc(100% - var(--s3) * 2); }
.m-side__link {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 50px; padding: 0 var(--s3);
  border-radius: var(--r-md); color: var(--ink-2);
  font-size: var(--fs-sm); font-weight: 600; text-decoration: none;
}
.m-side__link:hover { background: var(--surface-2); color: var(--ink); }
.m-side__link[aria-current="page"] { background: var(--brand-soft); color: var(--brand-deep); }
.m-side__ic { font-size: 20px; width: 24px; text-align: center; flex: none; }

@media (max-width: 900px) {
  .m-admin { grid-template-columns: 1fr; }
  .m-side  { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 60;
             transform: translateX(-100%); transition: transform var(--dur) var(--ease);
             box-shadow: var(--sh-3); }
  .m-side[data-open="true"] { transform: none; }
}
@media (min-width: 901px) { .m-side__toggle { display: none; } }

/* --------------------------------------------------------------- 12. STAT */

.m-stat { padding: var(--s5); background: var(--surface); border: 1px solid var(--line);
          border-radius: var(--r-lg); }
.m-stat__lbl { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em;
               text-transform: uppercase; color: var(--ink-3); }
.m-stat__val { margin-top: var(--s2); font-family: var(--font-display);
               font-size: var(--fs-2xl); font-weight: 600; line-height: 1;
               font-variant-numeric: tabular-nums; }
.m-stat__sub { margin-top: var(--s2); font-size: var(--fs-sm); color: var(--ink-3); }
.m-stat--accent { background: var(--brand-soft); border-color: var(--accent-line); }
.m-stat--accent .m-stat__val { color: var(--brand-deep); }

/* Pure-CSS bar chart. No JS, no library, no network. */
.m-bars { display: flex; align-items: flex-end; gap: 6px; height: 130px; }
.m-bars__b { flex: 1; background: var(--brand); border-radius: 4px 4px 0 0;
             min-height: 3px; opacity: .85; }
.m-bars__b:hover { opacity: 1; }
.m-bars__axis { display: flex; gap: 6px; margin-top: var(--s2); }
.m-bars__axis span { flex: 1; text-align: center; font-size: var(--fs-xs); color: var(--ink-3); }

.m-meter { height: 12px; border-radius: var(--r-pill); background: var(--surface-3);
           overflow: hidden; }
.m-meter__fill { height: 100%; background: var(--brand); border-radius: var(--r-pill); }
.m-meter__fill--warn   { background: var(--warn); }
.m-meter__fill--danger { background: var(--danger); }

/* -------------------------------------------------------------- 13. TABLE */

.m-tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch;
               border: 1px solid var(--line); border-radius: var(--r-lg);
               background: var(--surface); }
.m-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.m-table th {
  text-align: left; padding: var(--s4) var(--s5);
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-3); white-space: nowrap;
}
.m-table td { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line);
              vertical-align: middle; }
.m-table tbody tr:last-child td { border-bottom: 0; }
.m-table tbody tr:hover { background: var(--surface-2); }
.m-table__strong { font-weight: 650; color: var(--ink); }

/* ------------------------------------------------------------ 14. GALLERY */
/* Justified-ish grid via CSS columns. Deliberately NOT masonry-by-JS:
   JS masonry needs image dimensions, which means waiting on the network. */

.m-gal { columns: 2; column-gap: var(--s3); }
@media (min-width: 620px)  { .m-gal { columns: 3; column-gap: var(--s4); } }
@media (min-width: 980px)  { .m-gal { columns: 4; } }
@media (min-width: 1400px) { .m-gal { columns: 5; } }

.m-tile {
  position: relative; display: block; width: 100%;
  margin: 0 0 var(--s3); padding: 0; border: 0;
  break-inside: avoid; border-radius: var(--r-md); overflow: hidden;
  background: var(--surface-2); cursor: pointer;
  box-shadow: var(--sh-1);
}
@media (min-width: 620px) { .m-tile { margin-bottom: var(--s4); } }
.m-tile img { width: 100%; height: auto; display: block;
              transition: transform 300ms var(--ease); }
.m-tile:hover img { transform: scale(1.03); }

/* Placeholder used before the real thumb decodes — keeps layout from jumping */
.m-tile__ph { width: 100%; background: linear-gradient(150deg, var(--surface-2), var(--surface-3));
              display: grid; place-items: center; color: var(--ink-3); font-size: 28px; }

.m-tile__badge { position: absolute; top: var(--s2); left: var(--s2);
                 padding: 4px 9px; border-radius: var(--r-pill);
                 background: rgba(18,14,10,.72); color: #fff;
                 font-size: var(--fs-xs); font-weight: 700;
                 display: inline-flex; align-items: center; gap: 5px; }
.m-tile__foot { position: absolute; inset: auto 0 0 0; padding: var(--s5) var(--s3) var(--s3);
                background: linear-gradient(transparent, rgba(18,14,10,.78));
                color: #fff; font-size: var(--fs-xs); font-weight: 600;
                display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.m-tile__sel { position: absolute; top: var(--s2); right: var(--s2);
               width: 32px; height: 32px; border-radius: 50%;
               border: 2px solid #fff; background: rgba(18,14,10,.45); }
.m-tile[aria-selected="true"] { outline: 3px solid var(--brand); outline-offset: -3px; }
.m-tile[aria-selected="true"] .m-tile__sel { background: var(--brand); border-color: #fff; }

/* PHASE-4-LAUNCH.md A7 — a play badge on the grid tile, pure CSS so it costs the JS budget nothing. */
.m-tile[data-kind="video"]::after {
  content: "\25B6"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 48px; height: 48px; border-radius: 50%; background: rgba(18,14,10,.6);
  color: #fff; font-size: 18px; line-height: 48px; text-align: center; text-indent: 3px;
  pointer-events: none;
}

/* Skeleton shimmer for the first paint on a slow link */
.m-skel { background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%,
          var(--surface-2) 70%); background-size: 220% 100%;
          animation: m-shim 1.4s linear infinite; border-radius: var(--r-md); }
@keyframes m-shim { to { background-position: -220% 0; } }

/* ----------------------------------------------------------- 15. LIGHTBOX */

.m-lb { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column;
        background: #100D0A; color: #F6F0E6; }
.m-lb__bar { display: flex; align-items: center; gap: var(--s3);
             padding: var(--s3) var(--s4); padding-top: calc(var(--s3) + env(safe-area-inset-top));
             background: linear-gradient(rgba(0,0,0,.5), transparent); }
.m-lb__stage { flex: 1; display: grid; place-items: center; padding: var(--s3);
               min-height: 0; position: relative; }
.m-lb__stage img { max-width: 100%; max-height: 100%; width: auto; height: auto;
                   object-fit: contain; border-radius: var(--r-sm); }
.m-lb__nav { position: absolute; top: 50%; transform: translateY(-50%);
             width: var(--tap-lg); height: var(--tap-lg); border-radius: 50%;
             background: rgba(255,255,255,.14); border: 0; color: #fff;
             font-size: 28px; cursor: pointer; display: grid; place-items: center; }
.m-lb__nav--prev { left: var(--s3); }  .m-lb__nav--next { right: var(--s3); }
.m-lb__foot { padding: var(--s4); padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom));
              background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.m-lb__acts { display: flex; gap: var(--s2); margin-top: var(--s3); }
.m-lb__act { flex: 1; min-height: var(--tap); border-radius: var(--r-md);
             background: rgba(255,255,255,.12); border: 0; color: #fff;
             font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
             display: flex; flex-direction: column; align-items: center;
             justify-content: center; gap: 2px; }
.m-lb__act:hover { background: rgba(255,255,255,.2); }
.m-lb__act[aria-pressed="true"] { background: var(--brand); }

/* ------------------------------------------------------- 16. UPLOAD QUEUE */

.m-up { display: flex; gap: var(--s3); align-items: center;
        padding: var(--s3); border: 1px solid var(--line);
        border-radius: var(--r-md); background: var(--surface); }
.m-up + .m-up { margin-top: var(--s2); }
.m-up__thumb { width: 68px; height: 68px; border-radius: var(--r-sm); flex: none;
               object-fit: cover; background: var(--surface-2); }
.m-up__body  { flex: 1; min-width: 0; }
.m-up__name  { font-size: var(--fs-sm); font-weight: 650;
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-up__note  { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 2px; }
.m-up--done  { border-color: var(--ok); background: var(--ok-soft); }
.m-up--error { border-color: var(--danger); background: var(--danger-soft); }

.m-prog { height: 10px; margin-top: var(--s2); border-radius: var(--r-pill);
          background: var(--surface-3); overflow: hidden; }
.m-prog__fill { height: 100%; width: 0; background: var(--brand);
                border-radius: var(--r-pill); transition: width 300ms var(--ease); }
.m-prog__fill--ok    { background: var(--ok); }
.m-prog__fill--error { background: var(--danger); }

/* Drop zone / camera launcher */
.m-drop { display: flex; flex-direction: column; align-items: center; justify-content: center;
          gap: var(--s3); min-height: 190px; padding: var(--s6);
          border: 2.5px dashed var(--line-strong); border-radius: var(--r-lg);
          background: var(--surface); text-align: center; cursor: pointer; }
.m-drop:hover, .m-drop[data-drag="true"] { border-color: var(--brand); background: var(--brand-soft); }
.m-drop__ic { font-size: 46px; line-height: 1; }

/* --------------------------------------------------- 17. STATES & FEEDBACK */

.m-empty { text-align: center; padding: var(--s10) var(--s5); }
.m-empty__ic { font-size: 58px; line-height: 1; margin-bottom: var(--s4); opacity: .55; }
.m-empty__ttl { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; }
.m-empty__txt { margin-top: var(--s2); color: var(--ink-3); max-width: 42ch;
                margin-inline: auto; }

.m-note { display: flex; gap: var(--s3); padding: var(--s4);
          border-radius: var(--r-md); border: 1px solid var(--line);
          background: var(--surface-2); font-size: var(--fs-sm); line-height: 1.55; }
.m-note__ic { font-size: 20px; flex: none; line-height: 1.4; }
.m-note--ok     { background: var(--ok-soft);     border-color: transparent; color: var(--ok); }
.m-note--warn   { background: var(--warn-soft);   border-color: transparent; color: var(--warn); }
.m-note--danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.m-note--info   { background: var(--info-soft);   border-color: transparent; color: var(--info); }
.m-note--brand  { background: var(--brand-soft);  border-color: var(--accent-line); color: var(--ink-2); }

.m-toast { position: fixed; left: 50%; z-index: 95;
           bottom: calc(var(--tap) + var(--s7) + env(safe-area-inset-bottom));
           transform: translateX(-50%);
           display: flex; align-items: center; gap: var(--s3);
           min-height: 52px; padding: var(--s3) var(--s5);
           background: var(--ink); color: var(--paper);
           border-radius: var(--r-pill); box-shadow: var(--sh-3);
           font-size: var(--fs-sm); font-weight: 600; max-width: min(92vw, 460px); }

/* Connection banner. Appears the moment a request is slow, not only offline. */
.m-net { display: flex; align-items: center; gap: var(--s3);
         padding: var(--s3) var(--s5); background: var(--warn-soft);
         color: var(--warn); font-size: var(--fs-sm); font-weight: 600;
         border-bottom: 1px solid var(--line); }
.m-net--off { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------- 18. BOTTOM SHEET */
/* Preferred over centred modals on mobile: thumb-reachable, familiar. */

.m-scrim { position: fixed; inset: 0; z-index: 70; background: rgba(24,18,12,.55);
           backdrop-filter: blur(2px); }
.m-sheet {
  position: fixed; inset: auto 0 0 0; z-index: 71;
  max-height: 88dvh; overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-3);
  padding: var(--s3) var(--s5) calc(var(--s7) + env(safe-area-inset-bottom));
}
.m-sheet__grip { width: 46px; height: 5px; border-radius: var(--r-pill);
                 background: var(--line-strong); margin: 0 auto var(--s5); }
@media (min-width: 720px) {
  .m-sheet { inset: 50% auto auto 50%; transform: translate(-50%,-50%);
             width: min(560px, 92vw); border-radius: var(--r-xl); max-height: 84vh; }
  .m-sheet__grip { display: none; }
}

/* --------------------------------------------------------------- 19. TABS */

.m-tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--line);
          overflow-x: auto; -webkit-overflow-scrolling: touch; }
.m-tabs__t { display: inline-flex; align-items: center; gap: var(--s2);
             min-height: var(--tap); padding: 0 var(--s4);
             border: 0; border-bottom: 3px solid transparent; background: transparent;
             color: var(--ink-3); font-size: var(--fs-sm); font-weight: 650;
             white-space: nowrap; cursor: pointer; }
.m-tabs__t:hover { color: var(--ink); }
.m-tabs__t[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }

/* Filter chips — guest gallery. Horizontal scroll, no wrap, no dropdown. */
.m-chips { display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: var(--s2);
           -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.m-chips::-webkit-scrollbar { display: none; }
.m-chip { min-height: 48px; padding: 0 var(--s4); border-radius: var(--r-pill);
          border: 1.5px solid var(--line-strong); background: var(--surface);
          color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600;
          white-space: nowrap; cursor: pointer; }
.m-chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand);
                               color: var(--brand-on); }

/* ------------------------------------------------------------ 20. AVATARS */

.m-av { width: 44px; height: 44px; border-radius: 50%; flex: none;
        display: grid; place-items: center;
        background: var(--brand-soft); color: var(--brand-deep);
        font-weight: 700; font-size: var(--fs-sm); }
.m-av--lg { width: 60px; height: 60px; font-size: var(--fs-md); }

/* ----------------------------------------------------------- 21. QR / CARD */

.m-qr { display: grid; place-items: center; padding: var(--s5);
        background: #fff; border-radius: var(--r-md); border: 1px solid var(--line); }
.m-qr__img { width: 100%; max-width: 260px; aspect-ratio: 1; image-rendering: pixelated; }

/* A6 table card preview, scaled. Real output is 105x148mm PDF. */
.m-tablecard {
  width: 300px; aspect-ratio: 105 / 148;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s3); padding: var(--s5); text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--sh-2);
}
.m-tablecard--a5 { width: 300px; aspect-ratio: 148 / 210; }
.m-tablecard--classic { border: 2px solid var(--brand); }
.m-tablecard--modern { background: var(--brand-soft); border: 0; }
.m-tablecard--modern .m-tablecard__name { color: var(--brand-deep); }
.m-tablecard--minimal { border: 1px solid var(--line); }
.m-tablecard--minimal .m-eyebrow { color: var(--ink-3); }

/* --------------------------------------------------------- 22. LIVE WALL */

.m-wall { position: fixed; inset: 0; background: #0C0A08; color: #F6F0E6;
          overflow: hidden; }
.m-wall__mosaic { position: absolute; inset: 0; display: grid; gap: 8px; padding: 8px;
                  grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; }
.m-wall__cell { overflow: hidden; border-radius: var(--r-sm); background: #1A1510; }
.m-wall__cell img { width: 100%; height: 100%; object-fit: cover; }
.m-wall__cell--big { grid-column: span 2; grid-row: span 2; }
.m-wall__chrome { position: absolute; inset: auto 0 0 0; padding: var(--s6);
                  background: linear-gradient(transparent, rgba(0,0,0,.8));
                  display: flex; align-items: flex-end; justify-content: space-between;
                  gap: var(--s5); }
.m-wall__qr { background: #fff; padding: var(--s3); border-radius: var(--r-md); }
/* Below-40-items (C3) and the Slideshow/One-big-photo layouts (C2) all
   reduce to a small grid instead of the full 4-column mosaic. */
.m-wall__mosaic--wide { grid-template-columns: repeat(2, 1fr); }
.m-wall__mosaic--solo { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.m-wall__mosaic--solo .m-wall__cell--contain img { object-fit: contain; background: #000; }
.m-wall__cell { position: relative; }
.m-wall__cell video { width: 100%; height: 100%; object-fit: cover; }
.m-wall__cell--contain video { object-fit: contain; background: #000; }

/* ------------------------------------------------------------- 23. UTILITY */

.m-hide   { display: none !important; }
.m-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Skip link — first focusable element on every page */
.m-skip { position: absolute; left: -9999px; top: 0; z-index: 100;
          padding: var(--s3) var(--s5); background: var(--ink); color: var(--paper);
          border-radius: 0 0 var(--r-md) 0; font-weight: 650; }
.m-skip:focus { left: 0; }

.m-tc { text-align: center; }
.m-tr { text-align: right; }
.m-nowrap { white-space: nowrap; }
.m-mt0 { margin-top: 0 !important; }
.m-mt2 { margin-top: var(--s2); }
.m-mt4 { margin-top: var(--s4); }
.m-mt6 { margin-top: var(--s6); }
.m-mt7 { margin-top: var(--s7); }
.m-full { width: 100%; }

@media (max-width: 640px) { .m-hide-sm { display: none !important; } }
@media (min-width: 641px) { .m-only-sm { display: none !important; } }

/* Prototype-only ribbon. Never ships. */
.m-proto {
  position: fixed; right: 0; bottom: 0; z-index: 99;
  padding: 7px 14px; background: var(--ink); color: var(--paper);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em;
  border-radius: var(--r-md) 0 0 0; opacity: .82; text-decoration: none;
}
.m-proto:hover { opacity: 1; color: var(--paper); }

@media print {
  .m-topbar, .m-bottomnav, .m-fab, .m-side, .m-proto, .m-skip { display: none !important; }
  body { background: #fff; }
}
