/* ═══════════════════════════════════════════════════════════════════════════
   Album Project — Frontend Styles  v1.1
   Brand: Album.ke  |  Red: #B30000  |  Fonts: DM Serif Display + Inter
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  --ap-red:        #B30000;
  --ap-red-dark:   #8a0000;
  --ap-red-light:  #fdf0f0;
  --ap-dark:       #1a1614;
  --ap-grey-1:     #2d2926;
  --ap-grey-2:     #5a534e;
  --ap-grey-3:     #9a9188;
  --ap-grey-4:     #d8d0c8;
  --ap-grey-5:     #f0ece7;
  --ap-white:      #ffffff;
  --ap-bg:         #f7f4f0;
  --ap-card-bg:    #ffffff;
  --ap-radius:     10px;
  --ap-radius-lg:  18px;
  --ap-shadow:     0 1px 4px rgba(26,22,20,0.06), 0 4px 16px rgba(26,22,20,0.06);
  --ap-shadow-md:  0 2px 8px rgba(26,22,20,0.08), 0 8px 24px rgba(26,22,20,0.08);
  --ap-shadow-lg:  0 8px 40px rgba(26,22,20,0.16);
  --ap-transition: 0.18s ease;
  --ap-font-head:  'DM Serif Display', Georgia, serif;
  --ap-font-body:  'Inter', -apple-system, sans-serif;
}

/* ── App Container — full-bleed breakout from theme content column ──────────── */
.ap-app {
  font-family: var(--ap-font-body);
  color: var(--ap-grey-1);
  line-height: 1.6;
  background: var(--ap-bg);
  min-height: 100vh;

  /* Break out of the WordPress theme content column */
  width:       100vw;
  max-width:   100vw;
  margin-left:  calc(50% - 50vw);
  margin-right: 0;
  box-sizing:   border-box;
  position:     relative;
}
.ap-app * { box-sizing: border-box; }

/* ─────────────────────────────────────────────────────────────────────────────
   THEME OVERRIDE RESET
   WordPress themes (Twenty Twenty-Five etc.) apply opinionated button/svg/a
   styles that break our plugin UI. Scope-reset everything inside .ap-app.
   ───────────────────────────────────────────────────────────────────────────── */

/* Hard-reset all buttons inside the plugin */
.ap-app button {
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none !important;
  text-decoration: none;
  letter-spacing: normal;
  word-spacing: normal;
}

/* Ensure every SVG inside the plugin renders */
.ap-app svg {
  display: inline-block !important;
  overflow: visible !important;
  flex-shrink: 0;
  vertical-align: middle;
}

/* Prevent theme link styles bleeding into buttons and non-link elements */
.ap-app button a,
.ap-app a { text-decoration: none; }

/* ════════════════════════════════════════════════════════════════════════════
   HEADER — Compact two-column layout
   ════════════════════════════════════════════════════════════════════════════ */
.ap-header {
  position: relative;
  background: var(--ap-dark);
  overflow: hidden;
}

/* Cover photo bg layer — blurred behind overlay */
.ap-header-cover-bg {
  position: absolute;
  inset: 0;
  background-image: var(--cover);
  background-size: cover;
  background-position: center top;
  filter: blur(0px) brightness(0.55);
  transform: scale(1.02);
}

/* Gradient overlay for depth when cover exists */
.ap-header-has-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom,
    rgba(10,4,2,0.30) 0%,
    rgba(10,4,2,0.55) 100%);
  pointer-events: none;
}

/* Inner layout */
.ap-header-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px 36px 32px;
  color: white;
  min-height: 200px;
}

/* ── Left column ── */
.ap-header-left {
  flex: 1;
  min-width: 0;
}

.ap-header-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--ap-font-head);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.ap-header-logo-icon {
  display: flex;
  align-items: center;
  color: var(--ap-red);
  opacity: 0.9;
}

.ap-header-title {
  font-family: var(--ap-font-head);
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 400;
  margin: 0 0 4px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}

.ap-header-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  margin: 0 0 10px;
  line-height: 1.5;
  max-width: 500px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ap-header-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ap-stat {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
}
.ap-stat strong {
  font-weight: 600;
  color: rgba(255,255,255,0.85);
}
.ap-stat-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  display: inline-block;
}

/* ── Right column ── */
.ap-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* User pill */
.ap-header-user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 40px;
  padding: 6px 14px 6px 8px;
  backdrop-filter: blur(6px);
}

.ap-header-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ap-red);
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.ap-header-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1;
}
.ap-header-username {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 1px dashed rgba(255,255,255,0.3);
}
.ap-header-username:hover { border-bottom-color: rgba(255,255,255,0.7); }
.ap-username-input {
  font-size: 13px;
  font-weight: 500;
  color: var(--ap-dark);
  background: white;
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  width: 110px;
  outline: 2px solid rgba(255,255,255,0.6);
}

.ap-logout-btn {
  display: inline-flex;
  align-items: center;
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  transition: color var(--ap-transition);
  padding: 2px;
}
.ap-logout-btn:hover { color: rgba(255,255,255,0.9); }

/* ── Role Badge ─────────────────────────────────────────────────────────────── */
.ap-role-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.ap-role-owner            { background: rgba(179,0,0,0.25); color: #ff9999; }
.ap-role-manager          { background: rgba(200,90,0,0.22); color: #ffb878; }
.ap-role-contributor,
.ap-role-viewer,
.ap-role-tribute_editor   { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.6); }

/* Album Switcher */
.ap-album-switcher {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.ap-album-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  transition: all var(--ap-transition);
}
.ap-album-chip.active,
.ap-album-chip:hover {
  background: var(--ap-red);
  border-color: var(--ap-red);
  color: white;
}

/* ════════════════════════════════════════════════════════════════════════════
   NAVIGATION TABS
   ════════════════════════════════════════════════════════════════════════════ */
.ap-tabs {
  background: var(--ap-card-bg);
  border-bottom: 1px solid var(--ap-grey-5);
  box-shadow: 0 1px 0 var(--ap-grey-5), 0 2px 8px rgba(26,22,20,0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}
.ap-tabs-inner {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  gap: 2px;
}
.ap-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--ap-grey-3);
  font-size: 13.5px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color var(--ap-transition), border-color var(--ap-transition);
  white-space: nowrap;
}
.ap-tab svg { opacity: 0.7; }
.ap-tab:hover { color: var(--ap-red); }
.ap-tab:hover svg { opacity: 1; }
.ap-tab.active {
  color: var(--ap-red);
  border-bottom-color: var(--ap-red);
}
.ap-tab.active svg { opacity: 1; }

/* ════════════════════════════════════════════════════════════════════════════
   CONTENT PANELS
   ════════════════════════════════════════════════════════════════════════════ */
.ap-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 100px;
}
.ap-panel { display: none; }
.ap-panel.active { display: block; }

/* Panel Header */
.ap-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 16px;
}
.ap-panel-title {
  font-family: var(--ap-font-head);
  font-size: 26px;
  font-weight: 400;
  margin: 0;
  color: var(--ap-dark);
}
.ap-section-subtitle {
  font-size: 13px;
  font-weight: 600;
  color: var(--ap-grey-3);
  margin: 24px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ap-grey-5);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ════════════════════════════════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════════════════════════════════ */
.ap-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--ap-radius);
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--ap-font-body);
  cursor: pointer;
  transition: all var(--ap-transition);
  border: none;
  text-decoration: none;
  line-height: 1;
  letter-spacing: 0.01em;
}
.ap-btn-primary {
  background: var(--ap-red);
  color: white;
  box-shadow: 0 2px 8px rgba(179,0,0,0.25);
}
.ap-btn-primary:hover {
  background: var(--ap-red-dark);
  color: white;
  box-shadow: 0 4px 12px rgba(179,0,0,0.35);
  transform: translateY(-1px);
}
.ap-btn-outline {
  background: transparent;
  color: var(--ap-red);
  border: 1.5px solid var(--ap-red);
}
.ap-btn-outline:hover { background: var(--ap-red-light); }
.ap-btn-ghost {
  background: var(--ap-grey-5);
  color: var(--ap-grey-2);
}
.ap-btn-ghost:hover { background: var(--ap-grey-4); }
.ap-btn-sm { padding: 7px 14px; font-size: 13px; }
.ap-btn-full { width: 100%; justify-content: center; }
.ap-link-btn {
  background: none;
  border: none;
  color: var(--ap-red);
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
  font-family: var(--ap-font-body);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ap-link-btn.ap-danger { color: #c0392b; }
.ap-icon-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  border: none !important;
  background: var(--ap-grey-5) !important;
  cursor: pointer;
  transition: background var(--ap-transition);
  flex-shrink: 0 !important;
  overflow: hidden;
  line-height: 1 !important;
}
.ap-danger-icon { color: #c0392b !important; }
.ap-danger-icon:hover { background: #fde8e8 !important; }

/* ════════════════════════════════════════════════════════════════════════════
   CATEGORY BAR (pills + filters)
   ════════════════════════════════════════════════════════════════════════════ */
.ap-category-bar {
  margin: 22px 0 8px;
}

/* Scrollable pill row */
.ap-category-pills {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}

.ap-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--ap-grey-4);
  background: var(--ap-card-bg);
  color: var(--ap-grey-2);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--ap-font-body);
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
  user-select: none;
  box-shadow: 0 1px 3px rgba(26,22,20,0.05);
}
.ap-cat-pill:hover {
  border-color: var(--ap-red);
  color: var(--ap-red);
  background: var(--ap-red-light);
}
.ap-cat-pill.active {
  background: var(--ap-red);
  border-color: var(--ap-red);
  color: white;
  box-shadow: 0 2px 10px rgba(179,0,0,0.28);
}
.ap-cat-pill-add {
  border-style: dashed;
  color: var(--ap-red);
  border-color: rgba(179,0,0,0.4);
  background: transparent;
  box-shadow: none;
}
.ap-cat-pill-add:hover {
  background: var(--ap-red-light);
  border-color: var(--ap-red);
}
/* Drag-to-reorder pills */
.ap-cat-pill[draggable="true"] { cursor: grab; }
.ap-cat-pill[draggable="true"]:active { cursor: grabbing; }
.ap-cat-pill.ap-pill-dragging {
  opacity: 0.4;
  transform: scale(0.95);
  box-shadow: none;
}

/* Active filter label */
.ap-active-filter-label {
  font-size: 12.5px;
  color: var(--ap-grey-3);
  margin: 8px 0 0;
}

/* More Filters bar */
.ap-more-filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.ap-more-filters-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  font-size: 12.5px;
  font-family: var(--ap-font-body);
  color: var(--ap-grey-3);
  cursor: pointer;
  padding: 0;
  transition: color .15s;
}
.ap-more-filters-toggle:hover,
.ap-more-filters-toggle.active { color: var(--ap-red); }
.ap-filter-clear-all {
  font-size: 12px;
  background: none;
  border: none;
  color: var(--ap-red);
  cursor: pointer;
  font-family: var(--ap-font-body);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Secondary filters (hidden by default) */
.ap-secondary-filters {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 20px;
  margin-top: 10px;
  background: var(--ap-card-bg);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
  border: 1px solid var(--ap-grey-5);
}
.ap-filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ap-filter-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ap-grey-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.ap-filter-select {
  padding: 7px 10px;
  border: 1.5px solid var(--ap-grey-4);
  border-radius: var(--ap-radius);
  font-size: 13px;
  font-family: var(--ap-font-body);
  background: white;
  color: var(--ap-grey-1);
  cursor: pointer;
  min-width: 130px;
  transition: border-color var(--ap-transition);
}
.ap-filter-select:focus { outline: none; border-color: var(--ap-red); }

/* Create category inline row */
.ap-create-category-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.ap-create-cat-input { max-width: 280px; flex: 1; }

/* Loading state for photo grid */
.ap-photo-grid.ap-loading {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity .2s;
}

/* Inline create category inside upload modal */
.ap-inline-create-cat {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.ap-inline-create-cat .ap-input { flex: 1; min-width: 0; }
option.ap-create-option { font-style: italic; color: var(--ap-red); }

/* ════════════════════════════════════════════════════════════════════════════
   PHOTO GRID
   ════════════════════════════════════════════════════════════════════════════ */
.ap-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 4px 0;
}

.ap-photo-item {
  background: var(--ap-card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--ap-shadow);
  transition: transform var(--ap-transition), box-shadow var(--ap-transition);
  cursor: pointer;
  border: 1px solid rgba(26,22,20,0.06);
}
.ap-photo-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--ap-shadow-md);
}

.ap-photo-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}
.ap-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
  display: block;
}
.ap-photo-item:hover .ap-photo-wrap img { transform: scale(1.05); }

.ap-photo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 50%, rgba(0,0,0,0.45) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0;
  transition: opacity var(--ap-transition);
}
.ap-photo-item:hover .ap-photo-overlay { opacity: 1; }

.ap-photo-view-btn,
.ap-photo-delete-btn,
.ap-video-delete-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 38px !important;
  height: 38px !important;
  min-width: 38px !important;
  max-width: 38px !important;
  min-height: 38px !important;
  max-height: 38px !important;
  border-radius: 50% !important;
  border: none !important;
  padding: 0 !important;
  cursor: pointer;
  transition: transform var(--ap-transition), box-shadow var(--ap-transition);
  color: white !important;
  flex-shrink: 0 !important;
  overflow: hidden;
  line-height: 1 !important;
  text-decoration: none !important;
  box-sizing: border-box !important;
}
.ap-photo-view-btn   { background: rgba(255,255,255,0.22) !important; backdrop-filter: blur(4px); }
.ap-photo-delete-btn { background: rgba(179,0,0,0.85) !important; backdrop-filter: blur(4px); }
.ap-video-delete-btn { background: rgba(179,0,0,0.85) !important; backdrop-filter: blur(4px); }
.ap-photo-view-btn:hover,
.ap-photo-delete-btn:hover,
.ap-video-delete-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.ap-photo-caption {
  font-size: 12.5px;
  color: var(--ap-grey-2);
  padding: 9px 12px 11px;
  margin: 0;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FAMILY TREE
   ═══════════════════════════════════════════════════════════════════════════ */

/* Toolbar */
.ap-ft-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.ap-ft-toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ap-ft-people-count  { font-size: 13px; color: var(--ap-grey-3); }
.ap-ft-edit-hint     { font-size: 12px; color: var(--ap-grey-3); display: flex; align-items: center; gap: 4px; }

/* Zoom buttons */
.ap-ft-zoom-controls { display: flex; gap: 3px; }
.ap-ft-zoom-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--ap-grey-1);
  background: var(--ap-white);
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: var(--ap-dark);
  transition: background .15s;
  display: flex; align-items: center; justify-content: center;
}
.ap-ft-zoom-btn:hover { background: var(--ap-grey-1); }

/* Canvas wrapper */
.ap-ft-canvas-wrap {
  overflow: hidden;
  border: 1px solid var(--ap-grey-1);
  border-radius: 12px;
  background: #f9f8f6;
  min-height: 380px;
  cursor: grab;
  position: relative;
  user-select: none;
}
.ap-ft-canvas-wrap:active { cursor: grabbing; }

/* Canvas (pan + zoom target) */
.ap-ft-canvas {
  position: relative;
  padding: 40px 32px 56px;
  display: flex;
  flex-direction: column;
  gap: 0;
  transform-origin: top left;
  width: max-content;
  min-width: 100%;
}

/* SVG overlay for connection lines */
.ap-ft-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow: visible;
  pointer-events: none;
}
.ap-ft-line-spouse {
  stroke: var(--ap-red);
  stroke-width: 1.5;
  stroke-dasharray: 5 3;
  opacity: .55;
}
.ap-ft-line-parent  { stroke: #aaa; stroke-width: 1.5; opacity: .6; }
.ap-ft-spouse-ring  { fill: rgba(179,0,0,.1); stroke: var(--ap-red); stroke-width: 1; }
.ap-ft-spouse-heart { font-size: 9px; fill: var(--ap-red); font-family: sans-serif; }

/* Generation row */
.ap-ft-gen-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 0;
  position: relative;
}
.ap-ft-gen-row + .ap-ft-gen-row { border-top: 1px dashed #e0ddd8; }

.ap-ft-gen-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ap-grey-3);
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.ap-ft-gen-label::before,
.ap-ft-gen-label::after { content: ''; display: block; width: 40px; height: 1px; background: #ddd; }
.ap-ft-gen-label--muted { color: #bbb; font-style: italic; }

.ap-ft-gen-members {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px 20px;
}

/* Person card */
.ap-ft-person {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 108px;
  cursor: pointer;
  position: relative;
  transition: transform .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.ap-ft-person:hover  { transform: translateY(-4px); }
.ap-ft-person:focus  { outline: 2px solid var(--ap-red); outline-offset: 4px; border-radius: 8px; }

/* Avatar circle */
.ap-ft-avatar-wrap {
  width: 82px; height: 82px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #fff;
  box-shadow: 0 3px 14px rgba(0,0,0,.13);
  background: var(--ap-grey-1);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
  flex-shrink: 0;
  position: relative;
}
.ap-ft-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }

.ap-ft-initials {
  font-size: 30px;
  font-weight: 700;
  color: var(--ap-grey-3);
  font-family: 'DM Serif Display', serif;
  line-height: 1;
}

/* Card text */
.ap-ft-card-body { text-align: center; }
.ap-ft-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ap-dark);
  line-height: 1.3;
  word-break: break-word;
  max-width: 100px;
}
.ap-ft-years  { font-size: 11px; color: var(--ap-grey-3); margin-top: 2px; }
.ap-ft-photo-badge {
  display: inline-block;
  font-size: 10px;
  background: rgba(179,0,0,.08);
  color: var(--ap-red);
  border-radius: 10px;
  padding: 1px 8px;
  margin-top: 5px;
}

/* Edit button (appears on hover, owners only) */
.ap-ft-edit-btn {
  position: absolute;
  top: -4px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--ap-grey-1);
  color: var(--ap-grey-3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
  box-shadow: 0 1px 5px rgba(0,0,0,.12);
  z-index: 2;
}
.ap-ft-person:hover .ap-ft-edit-btn,
.ap-ft-person:focus-within .ap-ft-edit-btn { opacity: 1; }
.ap-ft-edit-btn:hover { background: var(--ap-red); color: #fff; border-color: var(--ap-red); }

/* ── Person Detail Drawer ───────────────────────────────────────────────── */
.ap-ft-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  background: #fff;
  box-shadow: -6px 0 40px rgba(0,0,0,.18);
  z-index: 9100;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
}
.ap-ft-drawer[aria-hidden="false"] { transform: translateX(0); }

.ap-ft-drawer-inner { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

.ap-ft-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 9099;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s;
}
.ap-ft-backdrop.open { opacity: 1; pointer-events: auto; }

.ap-ft-drawer-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 24px 18px 16px;
  border-bottom: 1px solid var(--ap-grey-1);
  flex-shrink: 0;
}
.ap-ft-drawer-avatar {
  width: 68px; height: 68px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--ap-grey-1);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ap-ft-drawer-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ap-ft-drawer-meta { flex: 1; min-width: 0; }
.ap-ft-drawer-name  { font-size: 18px; font-weight: 700; margin: 0 0 3px; line-height: 1.2; }
.ap-ft-drawer-years { font-size: 12px; color: var(--ap-grey-3); margin: 0 0 5px; }
.ap-ft-drawer-bio   { font-size: 13px; color: #666; margin: 0; line-height: 1.5; }
.ap-ft-drawer-close {
  background: none; border: none; cursor: pointer;
  font-size: 24px; color: var(--ap-grey-3); line-height: 1; padding: 0 0 0 8px; flex-shrink: 0;
}
.ap-ft-drawer-close:hover { color: var(--ap-dark); }

.ap-ft-drawer-photos {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-content: start;
}
.ap-ft-drawer-thumb-wrap {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
}
.ap-ft-drawer-thumb-wrap.ap-ft-avatar-active .ap-ft-drawer-thumb {
  outline: 3px solid var(--ap-red);
  outline-offset: -3px;
}
.ap-ft-drawer-thumb {
  width: 100%; aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
  display: block;
}
.ap-ft-drawer-thumb:hover { opacity: .85; transform: scale(1.03); }
.ap-ft-set-avatar-btn {
  position: absolute;
  bottom: 5px; right: 5px;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.65);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  padding: 0;
  line-height: 1;
}
.ap-ft-drawer-thumb-wrap:hover .ap-ft-set-avatar-btn { opacity: 1; }
.ap-ft-set-avatar-btn:hover { background: var(--ap-red); }
.ap-ft-drawer-msg {
  grid-column: 1/-1;
  text-align: center;
  color: var(--ap-grey-3);
  font-size: 13px;
  padding: 28px 0;
}
.ap-ft-drawer-footer {
  padding: 12px 18px 18px;
  border-top: 1px solid var(--ap-grey-1);
  flex-shrink: 0;
  text-align: center;
}

/* ── Edit Person Modal ──────────────────────────────────────────────────── */
.ap-ft-edit-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.52);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ap-ft-edit-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  max-height: 92vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.ap-ft-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--ap-grey-1);
  flex-shrink: 0;
}
.ap-ft-edit-header h3 { margin: 0; font-size: 17px; font-weight: 700; }
.ap-ft-edit-body   { padding: 18px 24px; display: flex; flex-direction: column; gap: 14px; }
.ap-ft-edit-footer {
  padding: 14px 24px 20px;
  border-top: 1px solid var(--ap-grey-1);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Mobile Accordion ───────────────────────────────────────────────────── */
.ap-ft-accordion { display: none; }

.ap-ft-acc-section {
  border: 1px solid var(--ap-grey-1);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}
.ap-ft-acc-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #fafaf9;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--ap-dark);
  text-align: left;
}
.ap-ft-acc-header:hover { background: #f3f2ef; }
.ap-ft-acc-count   { margin-left: auto; font-size: 12px; color: var(--ap-grey-3); font-weight: 400; }
.ap-ft-acc-chevron { flex-shrink: 0; transition: transform .2s; }
.ap-ft-acc-section.open .ap-ft-acc-chevron { transform: rotate(180deg); }

.ap-ft-acc-body {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 14px 16px 18px;
  flex-direction: row;
  gap: 16px;
}
.ap-ft-acc-body::-webkit-scrollbar { display: none; }
.ap-ft-acc-section:not(.open) .ap-ft-acc-body { display: none; }
.ap-ft-acc-section.open .ap-ft-acc-body { display: flex; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ap-ft-canvas-wrap    { display: none; }
  .ap-ft-accordion      { display: block; }
  .ap-ft-zoom-controls  { display: none; }
  .ap-ft-edit-hint      { display: none; }
  .ap-ft-drawer         { width: 100%; top: auto; bottom: 0; border-radius: 18px 18px 0 0; max-height: 88vh; }
  .ap-ft-edit-modal     { padding: 0; align-items: flex-end; }
  .ap-ft-edit-box       { border-radius: 18px 18px 0 0; max-height: 95vh; max-width: 100%; }
  .ap-ft-person         { width: 90px; }
  .ap-ft-avatar-wrap    { width: 70px; height: 70px; }
  .ap-ft-initials       { font-size: 24px; }
}

/* ── Sort Bar ─────────────────────────────────────────────────────────────── */
.ap-sort-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 10px;
  gap: 10px;
}
.ap-sort-left {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ap-grey-3);
}
.ap-select-sm {
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--ap-border);
  background: var(--ap-bg);
  color: var(--ap-text);
  cursor: pointer;
}
.ap-label-hint {
  font-size: 11px;
  color: var(--ap-grey-3);
  font-weight: 400;
}

/* ── Photo drag-to-reorder ────────────────────────────────────────────────── */
.ap-photo-draggable { cursor: grab; }
.ap-photo-draggable:active { cursor: grabbing; }
.ap-photo-drag-active { opacity: .45; transform: scale(.96); }
.ap-photo-drag-over { outline: 3px dashed var(--ap-red); outline-offset: 2px; border-radius: 8px; }

/* ── Edit Photo Modal ─────────────────────────────────────────────────────── */
.ap-edit-photo-thumb-wrap {
  text-align: center;
  background: var(--ap-grey-1);
  border-radius: 8px;
  overflow: hidden;
  max-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ap-edit-photo-thumb-wrap img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  display: block;
}
.ap-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--ap-border);
}

/* ── Drawer fullscreen ────────────────────────────────────────────────────── */
.ap-ft-drawer-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.ap-ft-drawer-fs-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ap-grey-3);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.ap-ft-drawer-fs-btn:hover { background: var(--ap-grey-1); color: var(--ap-text); }
.ap-ft-drawer.ap-ft-fullscreen {
  width: 100% !important;
  max-width: 100% !important;
  border-radius: 0;
  left: 0;
  right: 0;
}
.ap-ft-drawer.ap-ft-fullscreen .ap-ft-drawer-photos {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

/* ── Photo edit button in overlay ────────────────────────────────────────── */
.ap-photo-edit-btn {
  background: rgba(0,0,0,.55);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.ap-photo-edit-btn:hover { background: var(--ap-red); }

/* Under construction */
.ap-under-construction {
  text-align: center;
  padding: 80px 24px 100px;
  max-width: 520px;
  margin: 0 auto;
}
.ap-under-construction svg {
  margin-bottom: 24px;
  opacity: 0.85;
}
.ap-under-construction h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.75rem;
  color: var(--ap-dark);
  margin: 0 0 12px;
}
.ap-under-construction p {
  color: var(--ap-grey-3);
  font-size: 0.95rem;
  line-height: 1.65;
  margin: 0 0 24px;
}
.ap-uc-badge {
  display: inline-block;
  background: rgba(179,0,0,0.08);
  border: 1px solid rgba(179,0,0,0.25);
  color: var(--ap-red);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 20px;
}

/* Empty state */
.ap-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 24px;
  color: var(--ap-grey-3);
}
.ap-empty-state svg { opacity: 0.35; }
.ap-empty-state p { margin: 10px 0; font-size: 15px; }
.ap-load-more-wrap { text-align: center; padding: 36px 0 0; }

/* ════════════════════════════════════════════════════════════════════════════
   UPLOAD FAB
   ════════════════════════════════════════════════════════════════════════════ */
.ap-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px;
  padding: 13px 22px !important;
  background: var(--ap-red) !important;
  color: white !important;
  border: none !important;
  border-radius: 50px !important;
  font-size: 14.5px !important;
  font-weight: 600 !important;
  font-family: var(--ap-font-body) !important;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(179,0,0,0.42) !important;
  transition: all var(--ap-transition);
  z-index: 200;
  letter-spacing: 0.01em;
  text-decoration: none !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
.ap-fab:hover {
  background: var(--ap-red-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(179,0,0,0.52);
}

/* ════════════════════════════════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════════════════════════════════ */
.ap-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ap-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20,10,8,0.55);
  backdrop-filter: blur(4px);
}
.ap-modal-box {
  position: relative;
  background: white;
  border-radius: var(--ap-radius-lg);
  box-shadow: var(--ap-shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  animation: ap-modal-in 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
.ap-modal-lg { max-width: 700px; }
@keyframes ap-modal-in {
  from { opacity:0; transform:scale(0.93) translateY(12px); }
  to   { opacity:1; transform:scale(1)    translateY(0); }
}

.ap-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--ap-grey-5);
}
.ap-modal-header h3 {
  margin: 0;
  font-family: var(--ap-font-head);
  font-size: 22px;
  font-weight: 400;
  color: var(--ap-dark);
}
.ap-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--ap-grey-5);
  cursor: pointer;
  color: var(--ap-grey-2);
  transition: background var(--ap-transition);
  flex-shrink: 0;
}
.ap-modal-close:hover { background: var(--ap-grey-4); color: var(--ap-dark); }
.ap-modal-body { padding: 20px 24px 28px; }

/* ── Drop Zone ──────────────────────────────────────────────────────────────── */
.ap-drop-zone {
  border: 2px dashed var(--ap-grey-4);
  border-radius: var(--ap-radius);
  padding: 36px 24px;
  text-align: center;
  transition: all var(--ap-transition);
  cursor: pointer;
  background: var(--ap-grey-5);
}
.ap-drop-zone:hover {
  border-color: var(--ap-red);
  background: var(--ap-red-light);
}
.ap-drop-zone.drag-over {
  border-color: var(--ap-red);
  background: var(--ap-red-light);
}
.ap-drop-zone p { margin: 12px 0 4px; color: var(--ap-grey-2); font-size: 14px; }
.ap-upload-hint { font-size: 12px; color: var(--ap-grey-3); margin-top: 6px; }
.ap-upload-meta { margin-top: 16px; }
.ap-upload-queue { margin-top: 12px; max-height: 200px; overflow-y: auto; }
.ap-upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--ap-radius);
  background: var(--ap-grey-5);
  margin-bottom: 6px;
  font-size: 13px;
}
.ap-upload-item img { width: 40px; height: 32px; object-fit: cover; border-radius: 5px; }
.ap-upload-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-upload-progress {
  width: 100%;
  height: 3px;
  background: var(--ap-grey-4);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.ap-upload-progress-bar {
  height: 100%;
  background: var(--ap-red);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.ap-upload-status { font-size: 11px; color: var(--ap-grey-3); }
.ap-upload-status.done { color: #27ae60; }
.ap-upload-status.error { color: #c0392b; }
.ap-upload-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ════════════════════════════════════════════════════════════════════════════
   FORM ELEMENTS
   ════════════════════════════════════════════════════════════════════════════ */
.ap-form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.ap-form-field {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ap-flex-2 { flex: 2; }

.ap-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ap-grey-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ap-input,
.ap-select {
  padding: 9px 12px;
  border: 1.5px solid var(--ap-grey-4);
  border-radius: var(--ap-radius);
  font-size: 14px;
  font-family: var(--ap-font-body);
  color: var(--ap-grey-1);
  background: white;
  transition: border-color var(--ap-transition), box-shadow var(--ap-transition);
  width: 100%;
}
.ap-input:focus,
.ap-select:focus {
  outline: none;
  border-color: var(--ap-red);
  box-shadow: 0 0 0 3px rgba(179,0,0,0.08);
}
.ap-select-sm {
  padding: 5px 8px;
  font-size: 12px;
  border: 1.5px solid var(--ap-grey-4);
  border-radius: 6px;
  background: white;
  font-family: var(--ap-font-body);
}
.ap-hint { font-size: 11px; color: var(--ap-grey-3); }
.ap-form-hint { font-size: 12px; color: var(--ap-grey-3); margin: 6px 0 0; }

.ap-password-wrap { position: relative; }
.ap-password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ap-grey-3);
  padding: 0;
  display: flex;
}

/* ════════════════════════════════════════════════════════════════════════════
   STORIES
   ════════════════════════════════════════════════════════════════════════════ */
.ap-story-card {
  background: var(--ap-card-bg);
  border-radius: 12px;
  box-shadow: var(--ap-shadow);
  padding: 22px 26px;
  margin-bottom: 14px;
  transition: box-shadow var(--ap-transition), transform var(--ap-transition);
  border: 1px solid rgba(26,22,20,0.05);
}
.ap-story-card:hover {
  box-shadow: var(--ap-shadow-md);
  transform: translateY(-1px);
}
.ap-story-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.ap-story-type {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--ap-grey-5);
  color: var(--ap-grey-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ap-story-type-tribute { background: #fde8e8; color: #c0392b; }
.ap-story-type-history { background: #e8f4fd; color: #1a5276; }
.ap-story-type-elder   { background: #e8f5e9; color: #1a6634; }
.ap-gen-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--ap-grey-5);
  color: var(--ap-grey-2);
}
.ap-story-title {
  font-family: var(--ap-font-head);
  font-size: 21px;
  font-weight: 400;
  margin: 0 0 7px;
  color: var(--ap-dark);
}
.ap-story-excerpt {
  color: var(--ap-grey-2);
  font-size: 14px;
  margin: 0 0 14px;
  line-height: 1.65;
}
.ap-story-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ap-grey-3);
}
.ap-story-author,
.ap-story-date {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ap-story-actions { display: flex; gap: 4px; margin-left: auto; }
.ap-story-full-content {
  font-size: 15px;
  line-height: 1.8;
  color: var(--ap-grey-1);
}
.ap-story-full-content p { margin: 0 0 14px; }

/* ── Rich Editor ────────────────────────────────────────────────────────────── */
.ap-editor-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--ap-grey-5);
  border: 1.5px solid var(--ap-grey-4);
  border-radius: var(--ap-radius) var(--ap-radius) 0 0;
}
.ap-editor-btn {
  padding: 4px 10px;
  background: white;
  border: 1px solid var(--ap-grey-4);
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--ap-font-body);
  color: var(--ap-dark);
  transition: background var(--ap-transition);
}
.ap-editor-btn:hover { background: var(--ap-grey-4); }
.ap-rich-editor {
  border: 1.5px solid var(--ap-grey-4);
  border-top: none;
  border-radius: 0 0 var(--ap-radius) var(--ap-radius);
  padding: 14px;
  min-height: 120px;
  font-size: 15px;
  font-family: var(--ap-font-body);
  line-height: 1.7;
  outline: none;
  color: var(--ap-dark);
}
.ap-rich-editor:focus { border-color: var(--ap-red); }
.ap-rich-editor:empty:before {
  content: attr(data-placeholder);
  color: var(--ap-grey-4);
  pointer-events: none;
}
.ap-editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

/* ════════════════════════════════════════════════════════════════════════════
   TRIBUTE — multiple tribute cards (same layout as story cards)
   ════════════════════════════════════════════════════════════════════════════ */
/* Tribute cards reuse .ap-story-card layout; nothing extra needed by default.
   Keep legacy single-tribute selectors for backward-compat. */
.ap-tribute-section {
  background: var(--ap-card-bg);
  border-radius: 12px;
  box-shadow: var(--ap-shadow);
  padding: 36px 40px;
  margin-top: 8px;
  border: 1px solid rgba(26,22,20,0.05);
}
.ap-tribute-content {
  font-family: var(--ap-font-head);
  font-size: 18px;
  line-height: 1.95;
  color: var(--ap-grey-1);
}
/* Tribute card heart accent */
.ap-tribute-card .ap-story-type-tribute {
  background: #fde8e8;
  color: #c0392b;
}

/* ════════════════════════════════════════════════════════════════════════════
   MEMBERS — vertical profile cards
   ════════════════════════════════════════════════════════════════════════════ */
.ap-members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding: 8px 0;
}
.ap-member-card {
  background: var(--ap-card-bg);
  border-radius: 16px;
  box-shadow: var(--ap-shadow);
  padding: 24px 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
  border: 1px solid rgba(26,22,20,0.05);
  transition: box-shadow var(--ap-transition), transform var(--ap-transition);
  position: relative;
}
.ap-member-card:hover {
  box-shadow: var(--ap-shadow-md);
  transform: translateY(-2px);
}
/* Remove button — top right corner */
.ap-member-card .ap-member-remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
}
.ap-member-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--ap-red);
  color: white;
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  border: 3px solid var(--ap-grey-5);
}
.ap-member-info {
  width: 100%;
  min-width: 0;
  margin-bottom: 12px;
}
.ap-member-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--ap-dark);
  margin-bottom: 4px;
  word-break: break-word;
  line-height: 1.3;
}
.ap-member-email {
  font-size: 12px;
  color: var(--ap-grey-3);
  word-break: break-all;
  line-height: 1.4;
}
.ap-member-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}
/* Role select — full width in card */
.ap-member-controls .ap-member-role-select {
  flex: 1;
  min-width: 110px;
  font-size: 12px;
}
.ap-invite-form {
  background: var(--ap-card-bg);
  border-radius: 12px;
  box-shadow: var(--ap-shadow);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid rgba(26,22,20,0.05);
}
.ap-invite-form .ap-form-row { align-items: flex-end; }
.ap-pending-invites { margin-top: 24px; }
.ap-invite-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--ap-grey-5);
  font-size: 13px;
  flex-wrap: wrap;
}
.ap-invite-email { flex: 1; }
.ap-invite-expiry { color: var(--ap-grey-3); }

/* ════════════════════════════════════════════════════════════════════════════
   LIGHTBOX
   ════════════════════════════════════════════════════════════════════════════ */
.ap-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10,6,4,0.94);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ap-lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: calc(100vw - 140px);
  max-height: 90vh;
}
.ap-lightbox-img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.ap-lightbox-info {
  color: white;
  text-align: center;
  padding: 14px 0 0;
  width: 100%;
}
.ap-lightbox-caption {
  font-family: var(--ap-font-head);
  font-size: 18px;
  margin: 0 0 4px;
}
.ap-lightbox-meta {
  font-size: 12px;
  opacity: 0.5;
  margin: 0 0 12px;
}
.ap-lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--ap-transition);
}
.ap-lightbox-close:hover { background: rgba(255,255,255,0.22); }
.ap-lightbox-prev,
.ap-lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--ap-transition);
}
.ap-lightbox-prev { left: 16px; }
.ap-lightbox-next { right: 16px; }
.ap-lightbox-prev:hover,
.ap-lightbox-next:hover { background: rgba(255,255,255,0.22); }
.ap-lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.45);
  font-size: 12px;
}
.ap-lightbox-download {
  color: rgba(255,255,255,0.65) !important;
  border-color: rgba(255,255,255,0.25) !important;
  font-size: 13px;
  padding: 6px 14px;
}
.ap-lightbox-download:hover { color: white !important; border-color: white !important; }

/* ════════════════════════════════════════════════════════════════════════════
   LOGIN GATE
   ════════════════════════════════════════════════════════════════════════════ */
.ap-gate {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: linear-gradient(135deg, #160400 0%, #3d0000 50%, #1a0000 100%);
}
.ap-gate-box {
  background: white;
  border-radius: var(--ap-radius-lg);
  box-shadow: var(--ap-shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}
.ap-gate-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  justify-content: center;
}
.ap-gate-logo-text {
  font-family: var(--ap-font-head);
  font-size: 20px;
  color: var(--ap-red);
}
.ap-gate-title {
  font-family: var(--ap-font-head);
  font-size: 28px;
  font-weight: 400;
  text-align: center;
  margin: 0 0 8px;
  color: var(--ap-dark);
}
.ap-gate-subtitle {
  text-align: center;
  color: var(--ap-grey-3);
  font-size: 14px;
  margin: 0 0 24px;
}
.ap-gate-form .ap-form-field { margin-bottom: 16px; }
.ap-gate-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 0 20px;
  font-size: 13px;
}
.ap-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--ap-grey-2);
}
.ap-link { color: var(--ap-red); text-decoration: none; }
.ap-link:hover { text-decoration: underline; }
.ap-gate-footer {
  text-align: center;
  font-size: 13px;
  color: var(--ap-grey-3);
  margin-top: 20px;
}

/* ════════════════════════════════════════════════════════════════════════════
   INVITE ACCEPT PAGE
   ════════════════════════════════════════════════════════════════════════════ */
.ap-invite-page {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: linear-gradient(135deg, #160400 0%, #3d0000 50%, #1a0000 100%);
}
.ap-invite-box {
  background: white;
  border-radius: var(--ap-radius-lg);
  box-shadow: var(--ap-shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 440px;
  text-align: center;
}
.ap-invite-error svg { display: block; margin: 0 auto 16px; }
.ap-invite-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  font-family: var(--ap-font-head);
  font-size: 18px;
  color: var(--ap-red);
}
.ap-invite-box h2 {
  font-family: var(--ap-font-head);
  font-size: 26px;
  font-weight: 400;
  margin: 0 0 8px;
  color: var(--ap-dark);
}
.ap-invite-subtitle {
  color: var(--ap-grey-2);
  font-size: 14px;
  margin-bottom: 8px;
}
.ap-invite-email {
  font-size: 13px;
  color: var(--ap-grey-3);
  margin-bottom: 24px;
}
.ap-invite-existing {
  font-size: 13px;
  color: var(--ap-grey-2);
  text-align: left;
  margin-bottom: 12px;
}
.ap-invite-form-block { text-align: left; }
.ap-invite-form-block .ap-form-field { margin-bottom: 14px; }

/* ════════════════════════════════════════════════════════════════════════════
   ALERTS & TOAST
   ════════════════════════════════════════════════════════════════════════════ */
.ap-alert {
  padding: 12px 16px;
  border-radius: var(--ap-radius);
  font-size: 14px;
  margin-bottom: 16px;
}
.ap-alert-error   { background: #fde8e8; color: #c0392b; border: 1px solid #f5c6c6; }
.ap-alert-success { background: #e8f8e8; color: #27ae60; border: 1px solid #b8e0b8; }

.ap-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--ap-dark);
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 14px;
  z-index: 3000;
  opacity: 0;
  transition: all 0.28s ease;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}
.ap-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.ap-toast.ap-toast-error   { background: var(--ap-red); }
.ap-toast.ap-toast-success { background: #27ae60; }

/* ════════════════════════════════════════════════════════════════════════════
   UPLOAD MODAL SPECIFIC
   ════════════════════════════════════════════════════════════════════════════ */
.ap-upload-modal-box { max-width: 620px; }
.ap-form-field-full { flex: 1 100%; }

/* ── Select + Add button inline ─── */
.ap-select-add-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}
.ap-select-add-wrap .ap-select { flex: 1; }
.ap-add-term-btn {
  flex-shrink: 0;
  width: 32px;
  height: 36px;
  border: 1.5px solid var(--ap-grey-4);
  background: white;
  border-radius: var(--ap-radius);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--ap-red);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.ap-add-term-btn:hover {
  background: var(--ap-red-light);
  border-color: var(--ap-red);
}

/* ── EXIF badge ── */
.ap-exif-badge {
  display: inline-block;
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Multi-select people widget ── */
.ap-multiselect-wrap {
  position: relative;
  border: 1.5px solid var(--ap-grey-4);
  border-radius: var(--ap-radius);
  background: white;
  padding: 6px 8px;
  min-height: 40px;
  transition: border-color var(--ap-transition);
}
.ap-multiselect-wrap:focus-within {
  border-color: var(--ap-red);
  box-shadow: 0 0 0 3px rgba(179,0,0,0.08);
}
.ap-multiselect-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}
.ap-person-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--ap-red-light);
  color: var(--ap-red);
  border: 1px solid rgba(179,0,0,0.2);
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 500;
}
.ap-person-tag-remove {
  background: none;
  border: none;
  color: var(--ap-red);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  opacity: .6;
}
.ap-person-tag-remove:hover { opacity: 1; }
.ap-multiselect-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.ap-multiselect-search {
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  flex: 1;
  font-size: 13px;
  background: transparent;
  outline: none !important;
}
.ap-multiselect-dropdown {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 2px);
  background: white;
  border: 1.5px solid var(--ap-grey-4);
  border-radius: var(--ap-radius);
  max-height: 180px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: var(--ap-shadow-md);
}
.ap-multiselect-option {
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background .1s;
}
.ap-multiselect-option:hover {
  background: var(--ap-red-light);
  color: var(--ap-red);
}
.ap-multiselect-empty {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--ap-grey-3);
  font-style: italic;
}

/* ════════════════════════════════════════════════════════════════════════════
   CATEGORY MANAGEMENT TAB
   ════════════════════════════════════════════════════════════════════════════ */
.ap-cat-section {
  margin-bottom: 20px;
  border: 1px solid var(--ap-grey-5);
  border-radius: 12px;
  overflow: hidden;
  background: var(--ap-card-bg);
  box-shadow: var(--ap-shadow);
}
.ap-cat-section-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--ap-grey-5);
  background: #faf8f5;
}
.ap-cat-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ap-grey-2);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.ap-cat-add-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: #faf8f5;
  border-bottom: 1px solid var(--ap-grey-5);
  flex-wrap: wrap;
}
.ap-cat-add-form .ap-input {
  max-width: 240px;
  padding: 7px 11px;
  font-size: 13px;
}
.ap-cat-term-list { padding: 4px 0; }
.ap-cat-term-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--ap-grey-5);
  transition: background .1s;
}
.ap-cat-term-row:last-child { border-bottom: none; }
.ap-cat-term-row:hover { background: #faf8f5; }

.ap-cat-term-view {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}
.ap-cat-term-name {
  flex: 1;
  font-size: 14px;
  color: var(--ap-grey-1);
}
.ap-cat-term-count {
  font-size: 11px;
  color: var(--ap-grey-3);
  background: var(--ap-grey-5);
  padding: 1px 7px;
  border-radius: 10px;
}
.ap-cat-term-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.ap-cat-term-edit .ap-input {
  flex: 1;
  padding: 5px 10px;
  font-size: 13px;
}

/* ── Extra button sizes ── */
.ap-btn-xs {
  padding: 4px 11px;
  font-size: 11px;
  border-radius: 6px;
  border: 1.5px solid var(--ap-grey-4);
  background: white;
  cursor: pointer;
  font-family: var(--ap-font-body);
  color: var(--ap-grey-2);
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ap-btn-xs:hover { border-color: var(--ap-red); color: var(--ap-red); }
.ap-btn-danger   { color: #c0392b !important; border-color: #e8b4b8 !important; }
.ap-btn-danger:hover { background: #fff5f5 !important; }
.ap-btn-danger.ap-confirm-pending {
  background: #c0392b !important;
  color: white !important;
  border-color: #c0392b !important;
}

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .ap-header-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 16px;
    gap: 14px;
  }
  .ap-header-right {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  .ap-header-title { font-size: 22px; }
  .ap-header-desc  { display: none; }

  .ap-tabs-inner { overflow-x: auto; padding: 0 12px; gap: 0; }
  .ap-tab { padding: 12px 14px; font-size: 13px; }

  .ap-photo-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
  .ap-category-pills { gap: 6px; }
  .ap-cat-pill { padding: 6px 12px; font-size: 12px; }
  .ap-secondary-filters { gap: 8px; padding: 12px; }
  .ap-filter-select { min-width: 100px; font-size: 12px; }
  .ap-panel-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .ap-members-grid { grid-template-columns: 1fr; }
  .ap-fab { bottom: 16px; right: 16px; padding: 11px 18px; font-size: 13.5px; }
  .ap-modal-box { max-height: 96vh; }
  .ap-gate-box,
  .ap-invite-box { padding: 28px 20px; }
  .ap-lightbox-content { max-width: calc(100vw - 72px); }
  .ap-lightbox-prev { left: 8px; }
  .ap-lightbox-next { right: 8px; }
  .ap-tribute-section { padding: 20px 22px; }
  .ap-form-row { flex-direction: column; }
}

@media (max-width: 480px) {
  .ap-photo-grid { grid-template-columns: repeat(2, 1fr); }
  .ap-header-stats { font-size: 11px; }
}

/* ════════════════════════════════════════════════════════════════════════════
   VIDEO CARDS — YouTube thumbnail with persistent play badge
   ════════════════════════════════════════════════════════════════════════════ */

/* Persistent play badge (always visible, not just on hover) */
.ap-video-play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity var(--ap-transition);
}
.ap-video-play-badge svg {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.55));
  opacity: 0.9;
}

/* Darken slightly on hover so badge stays readable */
.ap-video-item .ap-photo-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.12);
  z-index: 1;
  transition: background var(--ap-transition);
  pointer-events: none;
}
.ap-video-item:hover .ap-photo-wrap::before { background: rgba(0,0,0,0.3); }

/* Push badge above the dim layer */
.ap-video-play-badge { z-index: 2; }

/* Red bottom strip to indicate video type */
.ap-video-item {
  border-bottom: 3px solid var(--ap-red) !important;
}

/* Caption icon */
.ap-video-caption-icon {
  font-size: 10px;
  color: var(--ap-red);
  margin-right: 3px;
}

/* ════════════════════════════════════════════════════════════════════════════
   FAB GROUP — stacked upload + video buttons
   ════════════════════════════════════════════════════════════════════════════ */
.ap-fab-group {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  z-index: 200;
}

/* Main upload FAB — keep existing .ap-fab styles, just remove position:fixed */
.ap-fab-group .ap-fab {
  position: static; /* override the fixed positioning */
}

/* Secondary (video) FAB — slightly smaller, different color */
.ap-fab-secondary {
  background: #1c1c1e !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35) !important;
  padding: 11px 18px !important;
  font-size: 13.5px !important;
}
.ap-fab-secondary:hover {
  background: #2c2c2e !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.45) !important;
}

/* ════════════════════════════════════════════════════════════════════════════
   VIDEO ADD MODAL — preview box
   ════════════════════════════════════════════════════════════════════════════ */
.ap-video-preview-box {
  position: relative;
  border-radius: var(--ap-radius);
  overflow: hidden;
  margin-bottom: 14px;
  background: #000;
  max-height: 180px;
}
.ap-video-preview-thumb {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  display: block;
  opacity: 0.85;
}
.ap-video-preview-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.ap-video-preview-play svg {
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6));
}

/* ════════════════════════════════════════════════════════════════════════════
   VIDEO PLAY MODAL — responsive 16:9 iframe embed
   ════════════════════════════════════════════════════════════════════════════ */
.ap-video-play-box {
  max-width: 860px !important;
}
.ap-video-play-body {
  padding: 0 0 20px !important;
}
.ap-video-embed-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 ratio */
  background: #000;
}
.ap-video-embed-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}
.ap-video-play-footer {
  display: flex;
  justify-content: flex-end;
  padding: 14px 20px 0;
}

/* ════════════════════════════════════════════════════════════════════════════
   CATEGORIES PANEL — heading, subtext, term actions, messages
   ════════════════════════════════════════════════════════════════════════════ */
.ap-categories-panel {
  padding-top: 8px;
}
.ap-panel-heading {
  font-family: var(--ap-font-head);
  font-size: 26px;
  font-weight: 400;
  color: var(--ap-dark);
  margin: 24px 0 6px;
}
.ap-panel-subtext {
  font-size: 14px;
  color: var(--ap-grey-3);
  margin: 0 0 20px;
}
.ap-cat-empty {
  padding: 14px 18px;
  font-size: 13px;
  color: var(--ap-grey-3);
  font-style: italic;
  margin: 0;
}
.ap-cat-term-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}
.ap-cat-msg {
  font-size: 12px;
  color: #27ae60;
  font-style: italic;
  min-width: 80px;
}
