/* =====================================================================
   bfiesta Private Gallery -- theme
   ---------------------------------------------------------------------
   Everything brand-specific lives in this one :root block: fonts, the
   accent color, and its tints. This file is written so the whole visual
   system can be reused for a different brand (e.g. a future "Lendot
   Living" file portal) just by swapping the values in this block --
   the layout/component rules below never hardcode a color or font.
   ===================================================================== */

:root {
  /* Fonts -- three distinct roles on purpose: the brand wordmark, page
     titles/editorial headings, and everyday interface text never share
     a family, so the brand never competes with a page heading. */
  --font-brand: 'Bodoni Moda', Didot, 'Times New Roman', serif;
  --font-heading: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-sans: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Brand accent -- rich wine/burgundy, red with a subtle purple
     undertone. Placeholder until the exact brand Pantone/HEX is
     supplied; swap just these three lines to re-theme the whole app
     (including for a future brand, e.g. "Lendot Living"). */
  --brand-accent: #7a1730;
  --brand-accent-hover: #5e1226;
  --brand-accent-soft: #f6e8eb;

  /* Neutral palette */
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f4f1ec;
  --text: #2b2622;
  --text-muted: #857c70;
  --text-faint: #a89e90;
  --border: #e8e2d9;
  --border-strong: #d8d0c3;

  /* Legacy aliases -- kept so every existing component rule below (and
     any future one) can keep referencing a generic "accent" name while
     still following the brand accent above. */
  --accent: var(--brand-accent);
  --accent-hover: var(--brand-accent-hover);
  --accent-soft: var(--brand-accent-soft);

  --danger: #c0453a;
  --danger-soft: #fbe9e7;
  --success: #3f7a5c;
  --success-soft: #e8f3ec;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(43, 38, 34, 0.06);
  --shadow-md: 0 8px 24px rgba(43, 38, 34, 0.10);
  --shadow-lg: 0 24px 64px rgba(43, 38, 34, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 0.5em; }
a { color: inherit; }

img { max-width: 100%; display: block; }
svg { display: block; }

/* ---------------------------------------------------------------- */
/* Top bar                                                           */
/* ---------------------------------------------------------------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  line-height: 1;
}
.brand {
  font-family: var(--font-brand);
  font-weight: 400;
  font-size: 1.55rem;
  letter-spacing: -0.005em;
  text-decoration: none;
  color: var(--text);
}
.brand-link .brand { white-space: nowrap; }
.brand-tagline {
  font-family: var(--font-sans);
  font-size: 0.42rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
  opacity: 0.62;
}
.topnav {
  display: flex;
  align-items: center;
  gap: 22px;
}
.topnav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
}
.topnav-link:hover { color: var(--text); }
.topnav-link.active { color: var(--text); border-bottom-color: var(--accent); }
.topnav-account {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 18px;
  margin-left: 4px;
  border-left: 1px solid var(--border);
}
.topnav-user {
  font-size: 0.82rem;
  color: var(--text-faint);
  white-space: nowrap;
}
.topnav-logout {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 7px;
  transition: background 0.15s ease, color 0.15s ease;
}
.topnav-logout:hover { color: var(--text); background: var(--surface-2); }
.nav-toggle {
  display: none;
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
}

/* ---------------------------------------------------------------- */
/* Layout                                                            */
/* ---------------------------------------------------------------- */
.main-content {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  padding-bottom: 22px;
  margin-bottom: 34px;
  border-bottom: 1px solid var(--border);
}
.page-eyebrow {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-faint);
  margin: 0 0 2px;
}
.page-title {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 1.3rem;
  letter-spacing: 0.005em;
  color: var(--text);
}
.page-subtitle {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.page-header-actions { display: flex; gap: 10px; }
.breadcrumb-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  margin-bottom: 8px;
}
.breadcrumb-back:hover { color: var(--text); }

.section { margin-bottom: 44px; }
.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.empty-state {
  color: var(--text-muted);
  padding: 28px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

/* ---------------------------------------------------------------- */
/* Buttons + form fields                                             */
/* ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.015em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  min-height: 44px;
}
.btn svg { flex: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-accent); border-color: var(--brand-accent); color: #fff; }
.btn-primary:hover { background: var(--brand-accent-hover); border-color: var(--brand-accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn-block { width: 100%; }

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin: 18px 0 6px;
}
.field-label:first-child { margin-top: 0; }
.field-hint {
  font-weight: 400;
  color: var(--text-faint);
  font-size: 0.8rem;
  display: block;
  margin-top: 2px;
}
.field-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
}
.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-input-center { text-align: center; letter-spacing: 0.15em; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  font-size: 0.92rem;
  cursor: pointer;
}
.toggle-row input { width: 18px; height: 18px; accent-color: var(--accent); }

.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.9rem;
}
.alert p { margin: 0; }
.alert p + p { margin-top: 4px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }

/* ---------------------------------------------------------------- */
/* Auth screens (entry code / admin login / setup)                   */
/* ---------------------------------------------------------------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 44px 36px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.auth-logo { margin-bottom: 6px; }
.brand-auth {
  display: block;
  font-size: clamp(1.6rem, 7vw, 2.4rem);
  line-height: 1.15;
  overflow-wrap: break-word;
  margin-bottom: 6px;
}
.auth-logo .brand-tagline { display: block; margin-bottom: 18px; }
.auth-subtitle {
  font-family: var(--font-heading);
  font-weight: 500;
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 28px;
}
.auth-note {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 18px;
}
.auth-form { text-align: left; }
.auth-form .btn { margin-top: 22px; }
.auth-footnote {
  color: var(--text-faint);
  font-size: 0.8rem;
  margin-top: 26px;
}
.auth-admin-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-faint);
  text-decoration: none;
}
.auth-admin-link:hover { color: var(--text-muted); text-decoration: underline; }

/* ---------------------------------------------------------------- */
/* Upload panel + dropzone                                           */
/* ---------------------------------------------------------------- */
.upload-panel { margin-bottom: 36px; }
.dropzone {
  background: var(--surface);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 44px 20px;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  margin: 0 auto 14px;
}
.dropzone-title { font-weight: 600; font-size: 1.05rem; margin-bottom: 2px; }
.dropzone-sub { color: var(--text-faint); font-size: 0.85rem; margin-bottom: 14px; }
.dropzone-hint { color: var(--text-faint); font-size: 0.8rem; margin-top: 14px; margin-bottom: 0; }

.upload-progress-list { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.upload-progress-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
}
.upload-progress-name {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 10px;
}
.upload-progress-name span:last-child { color: var(--text-faint); white-space: nowrap; }
.upload-progress-track {
  height: 6px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.15s ease;
}
.upload-progress-item.is-error .upload-progress-fill { background: var(--danger); }
.upload-progress-item.is-done .upload-progress-fill { background: var(--success); }
.upload-progress-error { color: var(--danger); margin-top: 4px; }

/* ---------------------------------------------------------------- */
/* Folder grid                                                       */
/* ---------------------------------------------------------------- */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 20px;
}
.folder-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.folder-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); transform: translateY(-1px); }
.folder-card:active { transform: translateY(0); }
.folder-card-link {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 16px 16px 14px;
}
.folder-card-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--brand-accent-soft);
  color: var(--brand-accent);
  margin-bottom: 10px;
}
.folder-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 3px;
  word-break: break-word;
  padding-right: 20px;
}
.folder-card-meta { color: var(--text-faint); font-size: 0.8rem; }
.folder-card-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
}
.folder-card.is-drag-over {
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-sm);
  background: var(--accent-soft);
}

/* ---------------------------------------------------------------- */
/* Icon buttons                                                      */
/* ---------------------------------------------------------------- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }

/* ---------------------------------------------------------------- */
/* Photo / file grid                                                 */
/* ---------------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 20px;
  align-items: start;
}
.grid-item { position: relative; }

.photo-tile {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.photo-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}
.photo-tile:hover img { transform: scale(1.04); }

.tile-actions {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 3;
}
.tile-menu-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(43, 38, 34, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  color: #fff;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease, opacity 0.15s ease;
}
/* Invisible hit-area padding so the tap target is a full 44px even though
   the visible button stays small and unobtrusive over the photo. */
.tile-menu-toggle::after {
  content: '';
  position: absolute;
  inset: -8px;
}
.tile-menu-toggle:hover,
.tile-menu-toggle:focus-visible { background: rgba(43, 38, 34, 0.68); }
.tile-actions.is-open .tile-menu-toggle { background: rgba(43, 38, 34, 0.68); }

/* On hover-capable devices, keep the toggle unobtrusive until the tile is
   hovered/focused so photos stay the focus; touch devices (no hover) show
   it plainly since there's no hover state to reveal it. */
@media (hover: hover) and (pointer: fine) {
  .tile-menu-toggle { opacity: 0; }
  .grid-item:hover .tile-menu-toggle,
  .grid-item:focus-within .tile-menu-toggle,
  .tile-actions.is-open .tile-menu-toggle { opacity: 1; }
}

.tile-menu {
  display: none;
  flex-direction: column;
  gap: 1px;
  position: absolute;
  top: 34px;
  right: 0;
  min-width: 152px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 5px;
}
.tile-actions.is-open .tile-menu { display: flex; }
.tile-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 44px;
  border: none;
  background: none;
  border-radius: 7px;
  padding: 0 10px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.tile-menu-item svg { flex: none; color: var(--text-muted); }
.tile-menu-item:hover,
.tile-menu-item:focus-visible { background: var(--surface-2); }
.tile-menu-item-danger { color: var(--danger); }
.tile-menu-item-danger svg { color: var(--danger); }
.tile-menu-item-danger:hover,
.tile-menu-item-danger:focus-visible { background: var(--danger-soft); }

.grid-item.is-dragging { opacity: 0.4; }

/* ---------------------------------------------------------------- */
/* Video tiles                                                       */
/* ---------------------------------------------------------------- */
.video-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.video-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.video-tile-poster {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #241f1c, #3c2530);
  overflow: hidden;
}
.video-tile-poster::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 42%, rgba(122, 23, 48, 0.38), transparent 68%);
}
.video-tile-poster::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.video-play-icon {
  position: relative;
  z-index: 1;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 3px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.video-tile:hover .video-play-icon { transform: scale(1.06); background: rgba(255, 255, 255, 0.24); }
.video-tile-label {
  position: absolute;
  left: 11px;
  bottom: 10px;
  z-index: 1;
  font-family: var(--font-sans);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}
.file-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.file-card-name {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-card-meta { color: var(--text-faint); font-size: 0.78rem; }
.file-card-actions {
  margin-top: auto;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ---------------------------------------------------------------- */
/* Modals                                                            */
/* ---------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  /* Fallback for browsers without dvh, then the real fix: dvh tracks the
     browser's currently-visible area, so this never renders taller than
     what's actually on screen when a mobile browser's toolbar shows or
     hides (the cause of a viewer that looks "cropped" or traps its own
     close button off-screen). */
  height: 100vh;
  height: 100dvh;
  background: rgba(30, 26, 22, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
           max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  z-index: 50;
  /* Safety net: if a modal's content is ever taller than the visible
     viewport (a long folder-picker list, a small-height landscape phone),
     the overlay itself scrolls so every control stays reachable instead
     of being trapped off-screen while body scroll is locked. */
  overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  margin: auto;
}
.modal-card h3 { font-size: 1.1rem; margin-bottom: 4px; }
.modal-subtext {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 4px 0 0;
  word-break: break-word;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.rename-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rename-file-row .field-input { flex: 1; min-width: 0; }
.rename-file-ext {
  color: var(--text-faint);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- */
/* Lightbox                                                          */
/* ---------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  background: rgba(15, 13, 11, 0.94);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
           max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.lightbox[hidden] { display: none; }
.lightbox-content {
  max-width: 90vw;
  max-height: 78vh;
  max-height: 78dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lightbox-content img {
  max-width: 90vw;
  max-height: 68vh;
  max-height: 68dvh;
  border-radius: 6px;
  object-fit: contain;
}
.lightbox-caption {
  color: #f1ede8;
  font-size: 0.85rem;
  margin-top: 14px;
  text-align: center;
  max-width: 80vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lightbox-close {
  position: absolute;
  top: 18px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: #f1ede8;
  cursor: pointer;
  transition: background 0.15s ease;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.2); }
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-download {
  position: absolute;
  bottom: 22px;
  right: 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-accent);
  color: #fff;
  text-decoration: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
}
.lightbox-download:hover { background: var(--brand-accent-hover); }
.lightbox-download[hidden] { display: none; }

/* ---------------------------------------------------------------- */
/* Video modal                                                       */
/* ---------------------------------------------------------------- */
.video-modal-card {
  max-width: 640px;
  max-height: 100%;
  padding: 0;
  overflow-y: auto;
  background: #000;
  position: relative;
  display: flex;
  flex-direction: column;
}
.video-modal-card video {
  width: 100%;
  max-height: 60vh;
  max-height: 60dvh;
  display: block;
  background: #000;
  object-fit: contain;
}
.video-modal-close {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 50%;
  color: #fff;
  z-index: 2;
}
.video-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px max(14px, env(safe-area-inset-bottom));
  background: var(--surface);
  flex-wrap: wrap;
}
.video-modal-caption {
  color: var(--text-muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-modal-footer .btn[hidden] { display: none; }

/* ---------------------------------------------------------------- */
/* Settings                                                          */
/* ---------------------------------------------------------------- */
.settings-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 20px;
  align-items: start;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
}
.card-title { font-size: 1.05rem; }
.card-title-spaced { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.settings-card .btn { margin-top: 26px; }

/* ---------------------------------------------------------------- */
/* Activity                                                          */
/* ---------------------------------------------------------------- */
.activity-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.activity-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.activity-row:last-child { border-bottom: none; }
.activity-main { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.activity-action { font-weight: 600; white-space: nowrap; }
.activity-detail {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-meta { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.activity-actor {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-muted);
}
.activity-actor-admin { background: var(--accent-soft); color: var(--accent-hover); }
.activity-date { color: var(--text-faint); font-size: 0.8rem; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}
.pagination-status { color: var(--text-faint); font-size: 0.85rem; }

/* ---------------------------------------------------------------- */
/* Mobile                                                            */
/* ---------------------------------------------------------------- */
@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .topnav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 20px 16px;
    gap: 4px;
    display: none;
  }
  .topnav.is-open { display: flex; }
  .topnav-link { width: 100%; padding: 10px 0; border-bottom: none; }
  .topnav-account {
    width: 100%;
    justify-content: space-between;
    padding: 10px 0 0;
    margin-left: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    margin-top: 4px;
  }
  .topnav-user { padding: 0; }
  .topnav-logout { padding: 5px 10px 5px 0; }

  .settings-grid { grid-template-columns: 1fr; }
  .main-content { padding-top: 20px; }
  .page-header {
    align-items: stretch;
    padding-bottom: 14px;
    margin-bottom: 20px;
    gap: 12px;
  }
  .page-eyebrow { font-size: 0.72rem; margin: 0 0 1px; }
  .page-title { font-size: 1.12rem; }
  .page-subtitle { font-size: 0.82rem; margin: 3px 0 0; }
  .page-header-actions { gap: 8px; }
  .page-header-actions .btn { flex: 1; }
  .section { margin-bottom: 30px; }
  .section-title { margin-bottom: 13px; }
  .folder-card-link { padding: 13px 14px 12px; }
  .folder-card-icon { width: 30px; height: 30px; margin-bottom: 8px; }
  .folder-card-name { font-size: 0.92rem; }
  .lightbox-nav { width: 40px; height: 40px; }
  .lightbox-prev { left: 6px; }
  .lightbox-next { right: 6px; }
  .lightbox-download { right: 12px; bottom: 14px; padding: 9px 14px; }
}

@media (max-width: 420px) {
  .page-header-actions .btn { padding-left: 12px; padding-right: 12px; font-size: 0.85rem; }
  .brand-link .brand { font-size: 1.15rem; white-space: normal; overflow-wrap: break-word; line-height: 1.15; }
  .brand-link .brand-tagline { font-size: 0.56rem; white-space: normal; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
  .folder-grid { gap: 14px; }
  .auth-card { padding: 34px 22px; }
  .modal { padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
                    max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .modal-card { padding: 22px; }
  .video-modal-footer { padding: 12px 14px max(12px, env(safe-area-inset-bottom)); }
}

/* Short / landscape phone screens -- give the media viewer less vertical
   room to work with so its controls never end up below the fold. */
@media (max-height: 500px) {
  .lightbox-content { max-height: 62vh; max-height: 62dvh; }
  .lightbox-content img { max-height: 48vh; max-height: 48dvh; }
  .video-modal-card video { max-height: 42vh; max-height: 42dvh; }
  .lightbox-nav { width: 36px; height: 36px; font-size: 1.3rem; }
}
