/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; -webkit-tap-highlight-color: transparent; }

/* ── Brand CSS variables ──
   Set per-show by the inline applyBranding() snippet that runs on every
   public page. Only --brand-text and --brand-font have global defaults
   (white text in Fira Sans). --brand-primary, --brand-accent, and
   --brand-bg-image are left undefined so the var() fallbacks in each
   usage produce the original Gregory Charles look on unbranded shows. */
:root {
  --brand-text: #ffffff;
  --brand-font: 'Fira Sans', sans-serif;
}

/* ── Body lock (chat page only) ──
   When the body has class "chat-body", we fully lock the page so the
   browser can't scroll the document at all. The whole UI is owned by
   .chat-wrap which is position:fixed and tracks the visual viewport.
   This kills:
     • iOS auto-scroll on input focus (page jumping up)
     • Android pull-to-refresh
     • Any rogue overscroll bounce
   Other pages (admin, display, ipad, index) are unaffected. */
body.chat-body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  /* Avoid iOS rubber-banding through the body */
  -webkit-overflow-scrolling: auto;
  /* Stop the OS from offering text-select on long-press of empty areas */
  -webkit-user-select: none;
  user-select: none;
  /* But re-enable selection inside actual messages and the input */
  touch-action: manipulation;
}
body.chat-body .msg-bubble,
body.chat-body .msg-input,
body.chat-body .msg-name,
body.chat-body .msg-time {
  -webkit-user-select: text;
  user-select: text;
}

/* ── Base ── */
body {
  /* --brand-bg is the solid color BEHIND .bg-photo (which is positioned
     fixed on top at low opacity). Falls back to #000 so unbranded shows
     keep the original dark theme. */
  background: var(--brand-bg, #000);
  color: var(--brand-text, #fff);
  font-family: var(--brand-font, 'Fira Sans', sans-serif);
  font-weight: 300;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Landing page ── */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* --brand-content-position is set by __applyBranding from shows.content_position
     ('flex-start' | 'center' | 'flex-end'). Default = center. */
  align-items: var(--brand-content-position, center);
  justify-content: center;
  padding: 40px 24px;
  position: relative;
  overflow: hidden;
}

.bg-photo {
  position: fixed;
  inset: 0;
  /* --brand-bg-position default = 'right center' (preserves legacy default
     image positioning); admin can override for photos with a focal point
     on a different side.
     --brand-bg-size default = 'cover' (fills viewport, crops as needed);
     admin can switch to 'contain' (whole image visible, may letterbox)
     or 'auto' (original pixel size, may tile). */
  background: var(--brand-bg-image, url('images/section1_bg.png'))
              var(--brand-bg-position, right center) / var(--brand-bg-size, cover) no-repeat;
  opacity: var(--brand-bg-opacity, 0.4);
  z-index: 0;
  pointer-events: none;
}

/* v1.0.30 — Portrait-mobile override.
   When the admin chose `contain` (whole image visible, no crop) for the
   desktop view, the same setting on a portrait phone scales a landscape
   image to fit the narrow WIDTH — leaving huge empty space above and
   below. On a portrait viewport we force `cover` regardless of the
   admin's setting, so the bg fills the screen and `bg_position` keeps
   the focal point visible. The desktop/tablet experience is unchanged.

   Threshold: aspect ratio <= 3/4 covers iPhone/Android phones in
   portrait. Landscape tablets and desktops fall through to the
   admin's chosen size. */
@media (max-aspect-ratio: 3/4) {
  .bg-photo { background-size: cover; }
}

.landing-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  /* --brand-content-align controls text alignment inside the form box
     (independent of where the box sits horizontally). Default = center. */
  text-align: var(--brand-content-align, center);
}

/* Logos: margin auto on both sides = centered. JS overrides per
   content_align ('left' → margin-end:auto only, 'right' → margin-start:auto only).
   v1.0.27 — Size driven by --brand-logo-size (set by JS from shows.logo_size).
   Default 200px preserves legacy GC look. */
.logo-main {
  max-width: var(--brand-logo-size, 200px);
  display: block;
  margin-block: 0 44px;
  margin-inline-start: var(--brand-logo-mgn-start, auto);
  margin-inline-end:   var(--brand-logo-mgn-end,   auto);
}
.logo-foot {
  max-width: 120px;
  display: block;
  margin-block: 48px 0;
  margin-inline-start: var(--brand-logo-mgn-start, auto);
  margin-inline-end:   var(--brand-logo-mgn-end,   auto);
  opacity: 0.4;
}
/* v1.0.31 — bumped from 0.3 → 0.55 for WCAG 2.1 AA contrast on black bg
   (was ~3.6:1 ratio, needs 4.5:1 for normal text). */
.copyright { font-size: 12px; color: rgba(255,255,255,0.55); margin-top: 10px; }

/* v1.0.31 — Skip-link. Visually hidden by default (off-screen) but
   focusable via Tab. When focused (keyboard nav), it snaps into view
   at the top of the page so users can jump straight to the form. */
.skip-link {
  position: fixed;
  top: -100px;
  left: 8px;
  background: #000;
  color: #fff;
  padding: 10px 16px;
  text-decoration: none;
  font-family: var(--brand-font, 'Fira Sans', sans-serif);
  font-size: 14px;
  border: 2px solid var(--brand-primary, #2196f3);
  border-radius: 4px;
  z-index: 100;
  transition: top 0.15s;
}
.skip-link:focus { top: 8px; }

.lang-toggle {
  /* v1.0.27 — Position controlled by --brand-lang-toggle-pos:
       'top-right' (default): top:18px; right:18px; left:auto
       'top-left':            top:18px; left:18px;  right:auto
       'hidden':              display:none (set on element itself by JS)
     JS sets the inset properties via two helper vars. */
  position: fixed;
  top: 18px;
  right: var(--brand-lang-toggle-right, 18px);
  left:  var(--brand-lang-toggle-left,  auto);
  /* All button-style vars: cascade fallbacks preserve the legacy look when
     the admin hasn't overridden anything. */
  border: 1px solid var(--brand-button-border, rgba(255,255,255,0.35));
  padding: 7px 13px;
  color: var(--brand-button-text, #fff);
  font-family: var(--brand-font, 'Fira Sans', sans-serif); font-size: 14px;
  /* v1.0.25 — Fallback to a dark translucent pill so the toggle stays
     legible over ANY custom bg image (especially when client uploads a
     bg with a logo in the top-right corner). Composites over a black
     body to ~black for the default GC look (visually unchanged) and
     gives clear separation over light/busy custom bgs. */
  background: var(--brand-button-bg, rgba(0,0,0,0.45));
  /* Frosted-glass effect on browsers that support it (graceful no-op
     on those that don't). Adds further separation from busy bgs. */
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer; border-radius: 4px;
  transition: background 0.2s;
  z-index: 10;
}
.lang-toggle:hover { background: rgba(255,255,255,0.1); }

.step { display: none; }
.step.active { display: block; }

/* Heading: own color so admins can pick distinct title vs body colors.
   v1.0.27 — Size scaled by --brand-heading-scale (multiplier 0.5–2.0,
   default 1.0). Default 21px × 1.0 = 21px preserves legacy size. */
.step h2 {
  font-size: calc(21px * var(--brand-heading-scale, 1));
  font-weight: 700; margin-bottom: 14px; line-height: 1.4;
  color: var(--brand-heading, inherit);
}
/* Body paragraph: separate from headings; uses --brand-text.
   v1.0.27 — Size scaled by --brand-body-scale (multiplier 0.5–2.0,
   default 1.0). */
.step p  {
  font-size: calc(15px * var(--brand-body-scale, 1));
  color: var(--brand-text, rgba(255,255,255,0.65));
  margin-bottom: 28px; line-height: 1.6;
}

.field { margin-bottom: 14px; }
.field input {
  width: 100%;
  padding: 14px 16px;
  /* Input chrome: separate vars so admin can theme the form's
     background + text without affecting other surfaces. */
  background: var(--brand-input-bg, rgba(255,255,255,0.07));
  border: 1px solid var(--brand-input-border, rgba(255,255,255,0.2));
  border-radius: 4px;
  color: var(--brand-input-text, #fff);
  font-family: var(--brand-font, 'Fira Sans', sans-serif); font-size: 16px;
  outline: none; transition: border-color 0.2s;
}
/* v1.0.31 — placeholder bumped 0.35 → 0.55 for WCAG AA. */
.field input::placeholder { color: var(--brand-input-placeholder, rgba(255,255,255,0.55)); }
.field input:focus { border-color: var(--brand-primary, rgba(255,255,255,0.55)); }

.btn-next {
  display: inline-flex; align-items: center; gap: 8px;
  /* By default the button is transparent and tinted with --brand-primary.
     Admins can override bg/border for a fully customizable button. */
  background: var(--brand-button-bg, none);
  border: var(--brand-button-border-style, none);
  color: var(--brand-button-text, var(--brand-primary, #fff));
  font-family: var(--brand-font, 'Fira Sans', sans-serif); font-size: 16px;
  cursor: pointer;
  /* JS sets --brand-btn-float to 'left' for left-aligned layout, defaults to
     'right'. The trailing <div style="clear:both"> handles either. */
  float: var(--brand-btn-float, right);
  padding: 8px 0; margin-top: 6px;
  opacity: 0.85; transition: opacity 0.2s;
}
.btn-next:hover:not(:disabled) { opacity: 1; }
.btn-next:disabled { opacity: 0.4; cursor: default; }
/* v1.0.24 — Accessibility: keyboard users can't tell where focus is when
   the button has no visible border. focus-visible only fires for keyboard
   nav (not mouse clicks), preserving the clean visual for pointer users.
   v1.0.31 — Expanded to a global rule covering every interactive element
   across the app. Any element that is keyboard-focusable in the DOM gets
   a visible 2px outline. Mouse users see nothing because :focus-visible
   only matches focus-via-keyboard, never focus-via-click. */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 2px solid var(--brand-primary, #2196f3);
  outline-offset: 2px;
  border-radius: 2px;  /* softens the outline on otherwise-square elements */
}

.err { color: #ff7070; font-size: 13px; margin-top: 6px; display: none; text-align: left; }
.err.show { display: block; }

/* ── Chat page wrapper ──
   The wrapper is position:fixed at inset:0 so it always fills the visual
   viewport. Its height is driven by --app-height, set by JS from
   window.visualViewport.height (mobile-keyboard-aware) with fallbacks:
     • --app-height set by JS (most accurate on all platforms)
     • 100dvh native dynamic viewport (fallback for browsers without VV)
     • 100vh oldest fallback (overshoots URL bar but works everywhere) */
.chat-wrap {
  position: fixed;
  inset: 0;
  display: flex; flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  /* No background — body is #000 and the .bg-photo sibling renders the
     show's bg image between body and chat-wrap. Setting an opaque bg
     here would hide bg-photo entirely. */
  background: transparent;
  overflow: hidden;
  /* iOS: respect notch/home-indicator safe areas */
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

.chat-header {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.chat-header .logo-sm { height: 32px; }
.chat-status { width: 8px; height: 8px; border-radius: 50%; background: #3a3a3a; transition: background 0.3s; }
.chat-status.connected { background: #4caf50; }
.chat-status.error { background: #f44336; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 6px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.msg {
  display: flex; flex-direction: column;
  max-width: 78%;
  animation: msgIn 0.2s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }

.msg-name {
  font-size: 11px;
  /* Dedicated msg-name color so admin can theme chat names without
     touching landing-page accents. Falls back to brand-accent, then to
     the original translucent white. */
  color: var(--brand-msg-name, var(--brand-accent, rgba(255,255,255,0.45)));
  margin-bottom: 3px;
  padding: 0 10px;
}

.msg-bubble {
  padding: 9px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
  /* Message body text inherits --brand-msg-text when set, else
     --brand-text, else white (via body). */
  color: var(--brand-msg-text, inherit);
}
.msg.mine .msg-bubble {
  background: var(--brand-msg-bubble, rgba(255,255,255,0.12));
  border-bottom-right-radius: 4px;
}
.msg.theirs .msg-bubble {
  background: var(--brand-msg-bubble, rgba(255,255,255,0.07));
  border-bottom-left-radius: 4px;
}

.msg-time {
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  margin-top: 3px;
  padding: 0 10px;
}

.scroll-btn {
  position: absolute; bottom: 80px; right: 16px;
  /* Primary brand color tints the scroll-to-bottom button —
     falls back to translucent white if no brand color set. */
  background: var(--brand-primary, rgba(255,255,255,0.15)); border: none;
  color: #fff; border-radius: 50%; width: 36px; height: 36px;
  font-size: 18px; cursor: pointer; display: none;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  z-index: 5;
}
.scroll-btn.show { display: flex; }

.chat-input-bar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.msg-input {
  flex: 1;
  background: var(--brand-input-bg, rgba(255,255,255,0.08));
  border: 1px solid var(--brand-input-border, rgba(255,255,255,0.15));
  border-radius: 22px;
  padding: 10px 16px;
  color: var(--brand-input-text, #fff);
  font-family: var(--brand-font, 'Fira Sans', sans-serif); font-size: 15px;
  outline: none; resize: none; max-height: 120px;
  overflow-y: auto; line-height: 1.4;
  transition: border-color 0.2s;
}
/* v1.0.31 — placeholder bumped 0.35 → 0.55 for WCAG AA. */
.msg-input::placeholder { color: var(--brand-input-placeholder, rgba(255,255,255,0.55)); }
.msg-input:focus { border-color: var(--brand-input-border, rgba(255,255,255,0.35)); }

.send-btn {
  flex-shrink: 0;
  width: 40px; height: 40px; border-radius: 50%;
  /* Primary brand color is the send button — most visible action.
     Falls back to translucent white if no brand color set. */
  background: var(--brand-primary, rgba(255,255,255,0.15)); border: none;
  color: #fff; font-size: 17px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: filter 0.2s, transform 0.1s;
}
.send-btn:active { transform: scale(0.9); }
.send-btn:hover { filter: brightness(1.15); }

.char-count {
  font-size: 11px; color: rgba(255,255,255,0.3);
  text-align: right; padding: 0 16px 4px;
  flex-shrink: 0;
}
.char-count.warn { color: #ff9800; }
.char-count.over { color: #f44336; }

/* ── Display page (big screen) ── */
.display-wrap {
  height: 100vh; height: 100dvh;
  /* Transparent so .bg-photo behind it can render the show's bg image.
     Body is already #000 so the page never goes lighter than black. */
  background: transparent;
  display: flex; flex-direction: column;
  overflow: hidden;
  padding: 32px 48px 40px;
  /* v1.0.25 — Without this, .bg-photo (position:fixed z-index:0) paints
     ON TOP of .display-wrap because positioned elements rank above
     non-positioned in the stacking order. Messages would briefly render
     during page load, then vanish under the bg image. position:relative
     + z-index:1 hoists this wrapper above the bg layer. (chat-wrap and
     ipad-wrap don't have this bug — they're already position:fixed /
     position:relative for other reasons.) */
  position: relative;
  z-index: 1;
}

.display-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 32px; flex-shrink: 0;
}
.display-logo { height: 50px; }
.display-count {
  font-size: 18px; color: rgba(255,255,255,0.4);
  font-style: italic;
}

.display-messages {
  flex: 1;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  gap: 20px;
}

.display-msg {
  animation: slideUp 0.4s cubic-bezier(0.22,1,0.36,1);
  overflow: hidden;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.display-msg-name {
  font-size: 22px;
  color: var(--brand-msg-name, var(--brand-accent, rgba(255,255,255,0.45)));
  margin-bottom: 6px;
  font-style: italic;
}
.display-msg-text {
  font-size: 48px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--brand-msg-text, var(--brand-text, #fff));
  word-break: break-word;
}

/* ── iPad page ── */
.ipad-wrap {
  height: 100vh; height: 100dvh;
  /* Transparent so .bg-photo can show through. Body is #000. */
  background: transparent;
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative; /* anchor for the floating follow-latest button */
}

/* Big "follow latest" button — always visible bottom-right.
   Subtle when auto-following, bright + pulsing when paused.
   Sized for confident on-stage tapping (≥80px on a moving target). */
.ipad-follow-btn {
  position: absolute;
  right: 24px;
  bottom: 24px;
  width: 92px; height: 92px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.65);
  font-family: var(--brand-font, 'Fira Sans', sans-serif);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  transition: transform 0.15s, background 0.2s, border-color 0.2s, color 0.2s;
  backdrop-filter: blur(8px);
  z-index: 50;
  /* Instant tap response on iOS — kills the legacy 300ms wait that some
     older iPads still apply to non-form-element click handlers */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  /* Respect home-indicator on iPad */
  margin-bottom: env(safe-area-inset-bottom, 0);
  margin-right: env(safe-area-inset-right, 0);
}
.ipad-follow-btn .ipad-follow-icon  { font-size: 32px; line-height: 1; }
.ipad-follow-btn .ipad-follow-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; margin-top: 2px; }
.ipad-follow-btn:active { transform: scale(0.92); }

/* Paused state: bright brand-primary + pulse → impossible to miss when on stage */
.ipad-follow-btn.paused {
  background: var(--brand-primary, rgba(33,150,243,0.85));
  border-color: rgba(255,255,255,0.4);
  color: #fff;
  animation: ipadFollowPulse 1.4s ease-in-out infinite;
  box-shadow: 0 4px 24px var(--brand-primary, rgba(33,150,243,0.4));
}
@keyframes ipadFollowPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

/* Accessibility: respect "Reduce Motion" — keep the colour cue (still
   immediately recognisable as paused) but drop the scale animation. */
@media (prefers-reduced-motion: reduce) {
  .ipad-follow-btn.paused { animation: none; }
}

.ipad-header {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.ipad-logo { height: 36px; }
.ipad-meta { text-align: right; }
.ipad-count { font-size: 22px; font-weight: 700; }
.ipad-count-label { font-size: 11px; color: rgba(255,255,255,0.4); }

/* Active show name, centered between the logo and the connected counter.
   Truncates rather than wrapping so the header stays one line tall. */
.ipad-show-title {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.02em;
  padding: 0 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ipad-messages {
  flex: 1; overflow-y: auto;
  /* Bottom padding leaves clearance for the floating follow-latest button
     (button is 92px + 24px from the bottom = 116px; we add a buffer so
     even at scroll-to-bottom the latest message text is fully visible). */
  padding: 16px 16px 130px 16px;
  display: flex; flex-direction: column; gap: 8px;
  -webkit-overflow-scrolling: touch;
  /* Stop iOS rubber-band on inner scroll from leaking to the page */
  overscroll-behavior: contain;
}

.ipad-msg {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  animation: msgIn 0.2s ease;
}
.ipad-msg.deleted { opacity: 0.3; text-decoration: line-through; }

.ipad-msg-body { flex: 1; min-width: 0; }
.ipad-msg-name { font-size: 20px; font-weight: 500; color: var(--brand-msg-name, var(--brand-accent, rgba(255,255,255,0.7))); margin-bottom: 5px; }
.ipad-msg-text { font-size: 22px; line-height: 1.35; word-break: break-word; color: var(--brand-msg-text, inherit); }

.ipad-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.ipad-btn {
  border: none; border-radius: 6px;
  font-size: 12px; padding: 5px 10px; cursor: pointer;
  font-family: var(--brand-font, 'Fira Sans', sans-serif);
  white-space: nowrap;
  transition: opacity 0.2s;
}
.ipad-btn:active { opacity: 0.7; }
.ipad-btn.del { background: rgba(244,67,54,0.25); color: #ff7070; }
.ipad-btn.sus { background: rgba(255,152,0,0.2); color: #ffb74d; }

/* ── Admin page ── */
.admin-login {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px;
}
.admin-login-box {
  width: 100%; max-width: 360px; text-align: center;
}
.admin-login-box h1 { font-size: 24px; margin-bottom: 8px; }
.admin-login-box p { color: rgba(255,255,255,0.5); margin-bottom: 28px; font-size: 14px; }
.admin-login-box input {
  width: 100%; padding: 13px 16px; margin-bottom: 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.2); border-radius: 4px;
  color: #fff; font-family: var(--brand-font, 'Fira Sans', sans-serif); font-size: 16px;
  outline: none;
}
.admin-login-box input:focus { border-color: rgba(255,255,255,0.45); }
.admin-login-btn {
  width: 100%; padding: 13px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px; color: #fff; font-family: var(--brand-font, 'Fira Sans', sans-serif);
  font-size: 16px; cursor: pointer; transition: background 0.2s;
}
.admin-login-btn:hover { background: rgba(255,255,255,0.18); }

.admin-wrap {
  height: 100vh; display: flex; flex-direction: column; overflow: hidden;
}
.admin-top {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.admin-top h1 { font-size: 18px; }
.admin-stats { font-size: 13px; color: rgba(255,255,255,0.45); }

.admin-cols {
  flex: 1; display: flex; overflow: hidden;
}
.admin-col {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; border-right: 1px solid rgba(255,255,255,0.08);
}
.admin-col:last-child { border-right: none; }
.admin-col-head {
  flex-shrink: 0; padding: 12px 16px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.05em;
  color: rgba(255,255,255,0.5); text-transform: uppercase;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.admin-col-body { flex: 1; overflow-y: auto; padding: 8px; }

.admin-msg {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 4px;
  background: rgba(255,255,255,0.04); transition: background 0.15s;
}
.admin-msg:hover { background: rgba(255,255,255,0.07); }
.admin-msg.deleted { opacity: 0.3; }
.admin-msg-body { flex: 1; min-width: 0; }
.admin-msg-meta { font-size: 11px; color: rgba(255,255,255,0.4); margin-bottom: 3px; }
.admin-msg-text { font-size: 14px; word-break: break-word; }

.admin-user {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 4px;
  background: rgba(255,255,255,0.04);
}
.admin-user.suspended { opacity: 0.5; }
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name { font-size: 14px; font-weight: 700; }
.admin-user-email { font-size: 11px; color: rgba(255,255,255,0.4); }
.admin-user-actions { display: flex; gap: 6px; }

.abtn {
  border: none; border-radius: 5px; padding: 5px 10px;
  font-size: 12px; cursor: pointer; font-family: var(--brand-font, 'Fira Sans', sans-serif);
  transition: opacity 0.2s;
}
.abtn:active { opacity: 0.7; }
.abtn:disabled { opacity: 0.3; cursor: not-allowed; }
.abtn.del  { background: rgba(244,67,54,0.2); color: #ff7070; }
.abtn.sus  { background: rgba(255,152,0,0.2); color: #ffb74d; }
.abtn.unsus{ background: rgba(76,175,80,0.2); color: #81c784; }
.abtn.act  { background: rgba(33,150,243,0.2); color: #64b5f6; }

/* ── Password eye-toggle (admin login + admin edit + display pw) ──
   The wrapper is the input's positioning context; the eye floats on
   the right edge and toggles input.type between password/text. */
.pw-wrap { position: relative; display: block; }
.pw-wrap > input { width: 100%; padding-right: 36px !important; }
.pw-wrap > .pw-eye {
  position: absolute;
  right: 6px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px;
  background: transparent; border: none; cursor: pointer;
  color: rgba(255,255,255,0.45);
  font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.pw-wrap > .pw-eye:hover { color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.06); }
.pw-wrap > .pw-eye.shown { color: #64b5f6; }

/* Like .abtn but for <a> tags — overrides browser default link colors with
   higher specificity. Used for preview links in the show edit modal. */
a.abtn-link, a.abtn-link:link, a.abtn-link:visited {
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 12px;
  font-family: var(--brand-font, 'Fira Sans', sans-serif);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
a.abtn-link:hover { background: rgba(33,150,243,0.25); color: #fff; border-color: rgba(33,150,243,0.5); }
a.abtn-link:active { opacity: 0.7; }

/* ─────────── Show-edit modal: collapsible sections + preview pane ─────────── */
.se-section {
  margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
}
.se-section > summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  user-select: none;
  list-style: none;
}
.se-section > summary::-webkit-details-marker { display: none; }
.se-section > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.15s;
}
.se-section[open] > summary::before { transform: rotate(90deg); }
/* Section body uses flex column so labels + inputs stack one-per-line
   like .admin-form's children do. Without this they default to inline
   flow and collapse onto a single row. */
.se-section-body {
  padding: 4px 14px 14px;
  display: flex; flex-direction: column;
  gap: 6px;
}
.se-section-body label {
  font-size: 12px; color: rgba(255,255,255,0.55);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-top: 8px;
}
.se-section-body input[type="text"],
.se-section-body input[type="email"],
.se-section-body input[type="url"],
.se-section-body input[type="date"],
.se-section-body input[type="password"] {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 9px 12px;
  color: #fff; font-family: 'Fira Sans', sans-serif; font-size: 14px;
  outline: none;
}
.se-section-body input:focus { border-color: rgba(255,255,255,0.4); }

.se-color-pick {
  width: 54px; height: 38px;
  cursor: pointer; background: none;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px; padding: 2px;
}
.se-color-hex {
  flex: 1;
  font-family: monospace !important;
  font-size: 13px !important;
}
.se-font-select {
  width: 100%; height: 38px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff; padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
}

.se-prev-tabs { display: flex; gap: 4px; }
.se-prev-tab {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.55);
  font-family: 'Fira Sans', sans-serif;
  font-size: 11px; line-height: 1;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}
.se-prev-tab:hover { color: #fff; }
.se-prev-tab.active {
  background: rgba(33,150,243,0.18);
  border-color: rgba(33,150,243,0.4);
  color: #64b5f6;
}
.se-prev-pane {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  height: 540px;
  display: flex;
  flex-direction: column;
  position: relative;
}
.se-prev-bg {
  position: absolute;
  inset: 0;
  background: url('images/section1_bg.png') right center / cover no-repeat;
  opacity: 0.4;
  z-index: 0;
  pointer-events: none;
}
.se-prev-content {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

/* ── Admin: tabs (Live | Admins) ── */
.admin-tabs { display: flex; gap: 4px; }
.admin-tab {
  background: transparent; border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.6);
  font-family: var(--brand-font, 'Fira Sans', sans-serif); font-size: 13px;
  padding: 6px 14px; border-radius: 4px;
  cursor: pointer; transition: all 0.15s;
}
.admin-tab:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-tab.active {
  background: rgba(33,150,243,0.18);
  border-color: rgba(33,150,243,0.4);
  color: #fff;
}

.admin-tab-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Admin: edit-admin modal form ── */
.admin-form { display: flex; flex-direction: column; gap: 6px; }
.admin-form label {
  font-size: 12px; color: rgba(255,255,255,0.55);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-top: 8px;
}
.admin-form input[type="text"],
.admin-form input[type="email"],
.admin-form input[type="password"] {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 9px 12px;
  color: #fff; font-family: var(--brand-font, 'Fira Sans', sans-serif); font-size: 14px;
  outline: none;
}
.admin-form input:focus { border-color: rgba(255,255,255,0.4); }
.admin-form input:disabled { opacity: 0.5; }
.admin-form input[type="checkbox"] { width: 16px; height: 16px; accent-color: #2196f3; }

/* ── Admin: show toolbar (above the two columns) ── */
.admin-shows-bar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
}
.admin-shows-label {
  font-size: 12px; color: rgba(255,255,255,0.5);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.admin-shows-select, .admin-shows-input {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 7px 10px;
  color: #fff; font-family: var(--brand-font, 'Fira Sans', sans-serif); font-size: 13px;
  outline: none;
  min-width: 220px;
}
.admin-shows-select:focus, .admin-shows-input:focus { border-color: rgba(255,255,255,0.4); }
.admin-shows-spacer { flex: 1; }

/* "Show archived" checkbox toggle in the show toolbar */
.admin-shows-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: rgba(255,255,255,0.7);
  cursor: pointer; user-select: none;
}
.admin-shows-toggle input[type="checkbox"] {
  accent-color: #2196f3; width: 14px; height: 14px;
}

/* ── Custom searchable combobox (replaces native <select>) ── */
/*
   Markup:
     .combobox > .combobox-input  (text field user types in)
              > .combobox-arrow   (▾ chevron, click toggles menu)
              > .combobox-menu    (absolutely-positioned dropdown)
                  > .combobox-item (one row per filtered option)
*/
.combobox { position: relative; min-width: 260px; }
.combobox-input { padding-right: 28px; width: 100%; }
.combobox-arrow {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  color: rgba(255,255,255,0.5); cursor: pointer;
  font-size: 14px; user-select: none;
  padding: 4px 6px;
}
.combobox-arrow:hover { color: rgba(255,255,255,0.9); }
.combobox-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 4px;
  max-height: 320px; overflow-y: auto;
  z-index: 60;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.combobox-item {
  padding: 8px 12px;
  display: flex; flex-direction: column; gap: 2px;
  cursor: pointer; font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.combobox-item:last-child { border-bottom: none; }
.combobox-item:hover, .combobox-item.selected {
  background: rgba(33,150,243,0.18);
}
.combobox-name { color: #fff; }
.combobox-meta { font-size: 11px; color: rgba(255,255,255,0.45); }
.combobox-empty {
  padding: 14px; text-align: center;
  color: rgba(255,255,255,0.4); font-size: 12px; font-style: italic;
}

/* Search box inside the Users column header */
.admin-user-search {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 5px 9px;
  color: #fff; font-family: var(--brand-font, 'Fira Sans', sans-serif); font-size: 12px;
  outline: none; text-transform: none; letter-spacing: 0;
}
.admin-user-search::placeholder { color: rgba(255,255,255,0.4); }
.admin-user-search:focus { border-color: rgba(255,255,255,0.35); }

/* Per-message action buttons (delete + suspend) in admin feed */
.admin-msg-actions { display: flex; gap: 5px; flex-shrink: 0; }
.admin-msg-actions .abtn { padding: 4px 8px; font-size: 13px; }

/* User-detail modal */
.admin-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
  backdrop-filter: blur(4px);
}
.admin-modal-box {
  width: 100%; max-width: 720px;
  max-height: 90vh; max-height: 90dvh;
  background: #111; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.admin-modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-shrink: 0;
}
.admin-modal-title { font-size: 18px; font-weight: 700; }
.admin-modal-sub   { font-size: 12px; color: rgba(255,255,255,0.5); margin-top: 2px; }
.admin-modal-body  { flex: 1; overflow-y: auto; padding: 12px; }

/* ── Suspended screen ── */
.suspended-screen {
  height: 100vh; height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 40px;
  /* v1.0.26 — Same z-index issue as the display-wrap bug. Without this,
     .bg-photo (position:fixed; z-index:0) paints ON TOP of the suspended
     screen and the suspension message is completely invisible. Banned
     users on a custom-bg show would see only the bg image with no
     explanation. Hoist above the bg layer. */
  position: relative;
  z-index: 1;
}
.suspended-screen h2 { font-size: 22px; margin-bottom: 12px; }
.suspended-screen p { color: rgba(255,255,255,0.55); font-size: 15px; }

/* ════════════════════════════════════════════════════════════════════════
   Mobile rules
   Layered tablet → phone → tiny phone, with each layer adjusting only
   what's needed at that size. Sizes chosen to match common breakpoints:
     • 720px = tablet portrait / small laptops
     • 480px = phone landscape / iPad split
     • 380px = small phones (iPhone SE, older Androids)
   ════════════════════════════════════════════════════════════════════════ */

/* Tablet & below: stack admin layout */
@media (max-width: 720px) {
  /* Top bar wraps so title, tabs, and stats can stack on narrow screens */
  .admin-top {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .admin-top h1 { font-size: 15px; }
  .admin-tabs { gap: 4px; }
  .admin-tab { padding: 5px 10px; font-size: 12px; }
  .admin-stats { font-size: 11px; flex-basis: 100%; text-align: right; }

  .admin-shows-bar { padding: 10px 12px; gap: 8px; }
  .admin-shows-select, .admin-shows-input { min-width: 0; flex: 1 1 100%; font-size: 14px; }
  .admin-shows-label { flex: 1 1 100%; }
  .admin-shows-spacer { display: none; }

  .admin-cols { flex-direction: column; }
  .admin-col { border-right: none; border-bottom: 1px solid rgba(255,255,255,0.08); min-height: 40vh; }
  .admin-col:last-child { border-bottom: none; }

  /* Modal goes full-screen on mobile (no padding around, sharp corners) */
  .admin-modal-box { max-height: 100vh; max-height: 100dvh; border-radius: 0; max-width: 100%; }
  .admin-modal { padding: 0; }
  /* Modal header wraps so action buttons drop below the title rather than crushing */
  .admin-modal-head { flex-wrap: wrap; padding: 12px 14px; }
  .admin-modal-head > div:last-child { flex-wrap: wrap; gap: 6px; }
}

/* Phone: tighten chat layout, prevent iOS auto-zoom on inputs */
@media (max-width: 480px) {
  .chat-header { padding: 10px 12px; }
  .chat-header .logo-sm { height: 28px; }
  .messages { padding: 12px 10px; }
  .msg { max-width: 85%; }
  .chat-input-bar { padding: 8px 10px; gap: 8px; }
  .send-btn { width: 40px; height: 40px; min-width: 40px; }  /* 40px = comfortable tap target */
  .msg-input { font-size: 16px; }                             /* ≥16px stops iOS zoom on focus */

  /* Landing-page form on phones: ≥16px input prevents iOS auto-zoom too */
  .field input { font-size: 16px; }

  /* Admin-login on phones: same treatment */
  .admin-login-box input { font-size: 16px; }
  .admin-form input[type="text"],
  .admin-form input[type="email"],
  .admin-form input[type="password"] { font-size: 16px; }

  /* Big screen on a phone (e.g. previewing): scale text down so it fits */
  .display-wrap { padding: 16px 18px 22px; }
  .display-logo { height: 36px; }
  .display-msg-name { font-size: 16px; margin-bottom: 4px; }
  .display-msg-text { font-size: 26px; }

  /* iPad view on a phone (Gregory testing): slightly smaller but still bold */
  .ipad-header { padding: 12px 14px; }
  .ipad-logo { height: 28px; }
  .ipad-count { font-size: 18px; }
  .ipad-msg { padding: 8px 10px; }
  .ipad-msg-name { font-size: 16px; margin-bottom: 3px; }
  .ipad-msg-text { font-size: 18px; }
}

/* Tiny phones (iPhone SE 1st gen, older Androids): one more squeeze */
@media (max-width: 380px) {
  .chat-header .logo-sm { height: 24px; }
  .msg-bubble { font-size: 14px; }
  .send-btn { width: 38px; height: 38px; min-width: 38px; }
  .admin-shows-select, .admin-shows-input { font-size: 13px; padding: 6px 8px; }
  .abtn { font-size: 11px; padding: 4px 8px; }
}

/* Tap-target floor: every interactive element gets ≥40px touch area on
   coarse pointers (mobile/tablet). Doesn't visually grow buttons that
   already had explicit sizes, just guarantees a usable hit area. */
@media (pointer: coarse) {
  .abtn, .lang-toggle, .admin-tab, .admin-login-btn, .btn-next {
    min-height: 36px;
  }
  .scroll-btn { width: 44px; height: 44px; }
}
