/* ═══════════════════════════════════════════════════════════
   FCC Memories Premium — memories-premium.css
   Scoped to #memories / .fcc-memories-page / .mem-* classes.
   Loads after adventures.css so it wins on specificity ties.
   ═══════════════════════════════════════════════════════════ */

/* ── Page shell ──────────────────────────────────────────── */
#memories.fcc-memories-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px 80px;
  background: transparent;
}

@media (max-width: 768px) {
  #memories.fcc-memories-page {
    padding: 12px 12px 80px;
  }
}

@media (max-width: 480px) {
  #memories.fcc-memories-page {
    padding: 8px 0 80px;
  }
}

/* ── Hero ────────────────────────────────────────────────── */
.mem-hero {
  position: relative;
  background: linear-gradient(135deg, #f0e8ff 0%, #f8e6ff 35%, #ffe4f5 65%, #fff3e4 100%);
  border-radius: 28px;
  padding: 40px 40px 32px;
  margin-bottom: 20px;
  overflow: hidden;
  color: #1a0a3d;
  box-shadow: 0 4px 32px rgba(108, 99, 255, 0.12), 0 0 0 1px rgba(180, 150, 255, 0.18);
}

@media (max-width: 640px) {
  .mem-hero {
    border-radius: 20px;
    padding: 24px 20px 22px;
    margin-bottom: 14px;
  }
}

.mem-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.82) 0%, transparent 40%),
    radial-gradient(circle at 20% 90%, rgba(255,230,245,0.6) 0%, transparent 38%);
  pointer-events: none;
}

.mem-hero::after {
  content: '✦ ✦ ✦';
  position: absolute;
  top: 18px;
  right: 180px;
  font-size: 10px;
  letter-spacing: 10px;
  color: rgba(160, 100, 255, 0.35);
  pointer-events: none;
}

.mem-hero-content {
  position: relative;
  z-index: 1;
}

.mem-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 20px;
}

@media (max-width: 600px) {
  .mem-hero-top {
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
  }
}

.mem-hero-eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #7c3aed;
  margin-bottom: 8px;
}

.mem-hero-title {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.5px;
  margin: 0 0 10px;
  color: #150940;
}

@media (max-width: 480px) {
  .mem-hero-title { font-size: 24px; }
}

.mem-hero-sub {
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
  max-width: 400px;
  color: #4b3a6b;
}

/* Illustration */
.mem-hero-illus {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
}

.mem-illus-photo {
  width: 66px;
  height: 66px;
  background: rgba(255,255,255,0.88);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(200,180,255,0.35);
  box-shadow: 0 8px 24px rgba(120,90,200,0.15), 0 2px 6px rgba(0,0,0,0.06);
  flex-shrink: 0;
}

.mem-illus-photo--1 { transform: rotate(-6deg); }
.mem-illus-photo--2 { transform: rotate(4deg) translateY(-6px); }
.mem-illus-photo--3 { transform: rotate(-2deg); }

.mem-illus-trophy {
  position: absolute;
  top: -18px;
  right: -8px;
  font-size: 26px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.22));
}

@media (max-width: 520px) {
  .mem-hero-illus { display: none; }
}

/* Stats row */
.mem-hero-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.mem-stat {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(200,180,255,0.3);
  border-radius: 16px;
  padding: 14px 20px;
  flex: 1;
  min-width: 110px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(100,80,180,0.1);
}

@media (max-width: 480px) {
  .mem-stat {
    min-width: calc(50% - 5px);
    padding: 10px 14px;
    flex: none;
    width: calc(50% - 5px);
    gap: 8px;
  }
}

.mem-stat-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.mem-stat-num {
  display: block;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  color: #150940;
}

.mem-stat-lbl {
  font-size: 11px;
  display: block;
  line-height: 1.25;
  color: #6b5a8a;
  margin-top: 2px;
}

/* Hero actions */
.mem-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.mem-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 60%, #c084fc 100%);
  color: #fff;
  border: none;
  border-radius: 22px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(124,58,237,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.mem-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(124,58,237,0.45);
}

.mem-btn-primary:active { transform: translateY(0); }

.mem-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.85);
  color: #7c3aed;
  border: 1.5px solid rgba(124,58,237,0.3);
  border-radius: 22px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.mem-btn-ghost:hover {
  background: rgba(255,255,255,0.96);
  box-shadow: 0 4px 16px rgba(124,58,237,0.2);
}

/* ── Form card ───────────────────────────────────────────── */
.mem-form-card {
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
  padding: 28px 28px 24px;
  margin-bottom: 18px;
}

body.dark-mode .mem-form-card {
  background: #1c1c2e;
  box-shadow: 0 2px 20px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.06);
}

@media (max-width: 640px) {
  .mem-form-card {
    border-radius: 18px;
    padding: 18px 14px 16px;
    margin-bottom: 12px;
  }
}

.mem-form-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

@media (max-width: 640px) {
  .mem-form-header {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
  }
}

.mem-form-header-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.mem-section-spark {
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}

.mem-form-title {
  font-size: 19px;
  font-weight: 800;
  color: #1a1a2e;
  margin: 0 0 3px;
  line-height: 1.2;
}

body.dark-mode .mem-form-title { color: #e5e7eb; }

.mem-form-sub {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
  line-height: 1.4;
}

/* Smart Fill badge */
.mem-smart-fill {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(108,99,255,0.06);
  border: 1px solid rgba(108,99,255,0.15);
  border-radius: 14px;
  padding: 10px 14px;
  flex-shrink: 0;
  max-width: 280px;
}

@media (max-width: 640px) {
  .mem-smart-fill { max-width: none; }
}

.mem-smart-fill-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.mem-smart-fill-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #6c63ff;
  line-height: 1;
  margin-bottom: 2px;
}

.mem-smart-fill-desc {
  display: block;
  font-size: 11px;
  color: #6b7280;
  line-height: 1.35;
}

.mem-smart-fill-info {
  cursor: help;
  color: #9ca3af;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Form body 2-col layout ──────────────────────────────── */
.mem-form-body {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

@media (max-width: 900px) {
  .mem-form-body {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

/* ── Upload column ───────────────────────────────────────── */
.mem-upload-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Drop zone */
.mem-dropzone {
  position: relative;
  border: 2px dashed rgba(108,99,255,0.3);
  border-radius: 18px;
  background: rgba(108,99,255,0.03);
  min-height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.mem-dropzone:hover {
  border-color: #6c63ff;
  background: rgba(108,99,255,0.05);
}

.mem-dropzone:focus {
  outline: none;
  border-color: #6c63ff;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.12);
}

.mem-dropzone.drag-over {
  border-color: #6c63ff;
  background: rgba(108,99,255,0.09);
  box-shadow: 0 0 0 4px rgba(108,99,255,0.15);
}

.mem-file-hidden {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.mem-dropzone-inner {
  text-align: center;
  padding: 24px 20px;
  pointer-events: none;
}

.mem-dropzone-cloud {
  font-size: 38px;
  margin-bottom: 10px;
  display: block;
}

.mem-dropzone-main {
  font-size: 15px;
  font-weight: 600;
  color: #374151;
  margin: 0 0 4px;
}

body.dark-mode .mem-dropzone-main { color: #d1d5db; }

.mem-dropzone-hint {
  font-size: 13px;
  color: #9ca3af;
  margin: 0;
}

/* Source buttons */
.mem-source-row {
  display: flex;
  gap: 7px;
}

.mem-source-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 8px;
  border: 1.5px solid rgba(0,0,0,0.09);
  border-radius: 12px;
  background: #fff;
  color: #374151;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}

.mem-source-btn:hover {
  border-color: #6c63ff;
  background: rgba(108,99,255,0.04);
  color: #6c63ff;
}

body.dark-mode .mem-source-btn {
  background: #2a2a3e;
  border-color: rgba(255,255,255,0.1);
  color: #d1d5db;
}

.mem-source-icon {
  font-size: 14px;
}

.mem-upload-hint-txt {
  font-size: 11.5px;
  color: #9ca3af;
  margin: 0;
  text-align: center;
}

/* Photo preview grid */
#memories .memory-photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 2px;
}

#memories .memory-photo-preview-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #f3f4f6;
  aspect-ratio: 1;
}

#memories .memory-photo-preview-item.is-cover {
  border-color: #6c63ff;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.2);
}

#memories .memory-photo-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#memories .memory-preview-meta {
  display: none;
}

#memories .memory-preview-actions {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.48);
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 5px;
  opacity: 0;
  transition: opacity 0.15s;
}

#memories .memory-photo-preview-item:hover .memory-preview-actions,
#memories .memory-photo-preview-item:focus-within .memory-preview-actions {
  opacity: 1;
}

#memories .memory-preview-actions button {
  flex: 1;
  padding: 4px 2px;
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 7px;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1.2;
}

#memories .memory-preview-actions button:hover {
  background: rgba(255,255,255,0.32);
}

/* Add More Photos */
.mem-add-more-btn {
  width: 100%;
  padding: 10px;
  border: 1.5px dashed rgba(108,99,255,0.28);
  border-radius: 12px;
  background: rgba(108,99,255,0.03);
  color: #6c63ff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.mem-add-more-btn:hover {
  background: rgba(108,99,255,0.07);
  border-color: #6c63ff;
}

/* ── Fields column ───────────────────────────────────────── */
.mem-fields-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Applies To */
.mem-applies-section {
  border-top: none !important;
  padding-top: 0 !important;
}

.mem-applies-header {
  margin-bottom: 8px;
}

.mem-applies-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #374151;
  display: block;
}

body.dark-mode .mem-applies-label { color: #d1d5db; }

/* Fields grid */
.mem-fields-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
}

.mem-field-wide {
  grid-column: span 2;
}

.mem-field-full {
  grid-column: 1 / -1;
}

@media (max-width: 700px) {
  .mem-fields-grid {
    grid-template-columns: 1fr 1fr;
  }
  .mem-field-wide { grid-column: span 2; }
}

@media (max-width: 480px) {
  .mem-fields-grid {
    grid-template-columns: 1fr;
  }
  .mem-field-wide { grid-column: auto; }
}

.mem-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mem-field-full {
  grid-column: 1 / -1;
}

.mem-label {
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  display: block;
}

body.dark-mode .mem-label { color: #d1d5db; }

.mem-req {
  color: #ef4444;
  font-weight: 700;
}

.mem-opt {
  font-weight: 400;
  color: #9ca3af;
  font-size: 11px;
}

/* Inputs */
#memories .mem-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  color: #1a1a2e;
  font-size: 13.5px;
  line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
  font-family: inherit;
}

body.dark-mode #memories .mem-input {
  background: #2a2a3e;
  border-color: rgba(255,255,255,0.1);
  color: #e5e7eb;
}

#memories .mem-input:focus {
  border-color: #6c63ff;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.12);
  outline: none;
}

#memories select.mem-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
  cursor: pointer;
}

#memories textarea.mem-input {
  min-height: 88px;
  resize: vertical;
}

.mem-notes-count {
  font-size: 11px;
  color: #9ca3af;
  text-align: right;
  margin-top: -2px;
}

/* Form actions */
.mem-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.mem-btn-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #6c63ff, #9b8bfb);
  color: #fff;
  border: none;
  border-radius: 22px;
  padding: 12px 26px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(108,99,255,0.38);
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.mem-btn-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(108,99,255,0.48);
}

.mem-btn-save:active { transform: translateY(0); }

.mem-btn-cancel {
  display: inline-flex;
  align-items: center;
  padding: 11px 20px;
  border: 1.5px solid rgba(0,0,0,0.1);
  border-radius: 22px;
  background: rgba(0,0,0,0.04);
  color: #6b7280;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.mem-btn-cancel:hover {
  background: rgba(0,0,0,0.08);
}

.mem-btn-cancel.hidden {
  display: none !important;
}

/* ── Gallery card ────────────────────────────────────────── */
.mem-gallery-card {
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
  padding: 24px 24px 28px;
}

body.dark-mode .mem-gallery-card {
  background: #1c1c2e;
  box-shadow: 0 2px 20px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.06);
}

@media (max-width: 640px) {
  .mem-gallery-card {
    border-radius: 18px;
    padding: 16px 14px 20px;
  }
}

.mem-gallery-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

@media (max-width: 640px) {
  .mem-gallery-header {
    flex-direction: column;
    gap: 10px;
  }
}

.mem-gallery-title-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.mem-gallery-title {
  font-size: 19px;
  font-weight: 800;
  color: #1a1a2e;
  margin: 0 0 3px;
  line-height: 1.2;
}

body.dark-mode .mem-gallery-title { color: #e5e7eb; }

.mem-gallery-sub {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
}

.mem-gallery-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  position: relative;
}

.mem-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.mem-search-input {
  padding: 8px 14px 8px 34px;
  border: 1.5px solid #e5e7eb;
  border-radius: 22px;
  background: #f9fafb;
  font-size: 13px;
  color: #374151;
  width: 210px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  font-family: inherit;
  box-sizing: border-box;
}

.mem-search-input:focus {
  border-color: #6c63ff;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.12);
  outline: none;
  background: #fff;
}

@media (max-width: 480px) {
  .mem-search-input { width: 100%; }
}

.mem-search-icon {
  position: absolute;
  left: 10px;
  font-size: 14px;
  pointer-events: none;
  color: #9ca3af;
}

/* Filter row */
.mem-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}

.mem-filter-group {
  flex: 1;
  min-width: 120px;
}

.mem-filter-select {
  width: 100%;
  padding: 7px 28px 7px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 22px;
  background: #f9fafb;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  appearance: none;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: border-color 0.15s;
  font-family: inherit;
  box-sizing: border-box;
}

.mem-filter-select:focus {
  border-color: #6c63ff;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.12);
  outline: none;
}

.mem-clear-filters-btn {
  padding: 7px 16px;
  border: 1.5px solid #e5e7eb;
  border-radius: 22px;
  background: #f9fafb;
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
  font-family: inherit;
}

.mem-clear-filters-btn:hover {
  border-color: #6c63ff;
  color: #6c63ff;
}

/* ── Tag filter chips (override existing) ────────────────── */
#memories .memory-tag-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

#memories .memory-filter-chip {
  padding: 5px 14px;
  border-radius: 22px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1.5px solid rgba(0,0,0,0.08);
  cursor: pointer;
  transition: all 0.15s;
  background: #f3f4f6;
  color: #374151;
  line-height: 1.4;
}

#memories .memory-filter-chip:hover {
  border-color: #6c63ff;
  color: #6c63ff;
  background: rgba(108,99,255,0.05);
}

#memories .memory-filter-chip.is-active {
  background: rgba(108,99,255,0.1);
  color: #6c63ff;
  border-color: rgba(108,99,255,0.3);
}

#memories .memory-filter-chip--all.is-active {
  background: #6c63ff;
  color: #fff;
  border-color: #6c63ff;
}

/* ── Memory timeline ─────────────────────────────────────── */
#memories .memory-timeline {
  margin-top: 6px;
}

#memories .memory-timeline-group {
  margin-bottom: 24px;
}

#memories .memory-group-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  font-weight: 800;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 24px 0 12px;
  padding-bottom: 0;
  border-bottom: none;
}

#memories .memory-group-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, #e5e7eb 0%, transparent 100%);
}

/* ── Memory card grid ────────────────────────────────────── */
#memories .memory-list-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 0;
}

@media (max-width: 900px) {
  #memories .memory-list-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

@media (max-width: 520px) {
  #memories .memory-list-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* Card */
#memories .memory-card {
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(178, 160, 255, 0.24);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 16px 42px rgba(41, 31, 84, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  display: flex;
  flex-direction: column;
}

body.dark-mode #memories .memory-card {
  background: #1c1c2e;
  box-shadow: 0 2px 14px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.06);
}

#memories .memory-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 52px rgba(41, 31, 84, 0.12);
  border-color: rgba(145, 105, 255, 0.32);
}

#memories .memory-card:focus-within {
  box-shadow: 0 0 0 3px rgba(108,99,255,0.25), 0 2px 14px rgba(0,0,0,0.07);
}

/* Card image area */
#memories .memory-thumb-wrap {
  position: relative;
  width: calc(100% - 24px);
  margin: 12px 12px 0;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 20px 20px 14px 14px !important;
  background: #f7f1ff;
  clip-path: none !important;
}

#memories .memory-thumb-btn {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  line-height: 0;
  overflow: hidden;
  border-radius: inherit !important;
  clip-path: none !important;
}

#memories .memory-thumb {
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.3s ease;
  border-radius: inherit !important;
  clip-path: none !important;
  shape-outside: none !important;
}

#memories .memory-card:hover .memory-thumb {
  transform: scale(1.03);
}

#memories .memory-thumb-placeholder {
  width: calc(100% - 24px);
  margin: 12px 12px 0;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  color: #a78bfa;
  font-size: 0.9rem;
  font-weight: 800;
  border-radius: 20px 20px 14px 14px !important;
  clip-path: none !important;
}

#memories .memory-photo-count-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid rgba(160, 125, 255, 0.25);
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
  color: #6d3cf5;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(55, 35, 120, 0.12);
  backdrop-filter: blur(10px);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

#memories .memory-photo-count-badge:hover,
#memories .memory-photo-count-badge:focus-visible {
  background: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(55, 35, 120, 0.16);
  outline: none;
}

/* Category badge on image */
.mem-card-cat-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  background: rgba(255,255,255,0.92);
  color: #6c63ff;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.6);
  white-space: nowrap;
  line-height: 1.5;
}

/* Card body */
#memories .memory-card-body {
  padding: 14px 16px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#memories .memory-child-name {
  font-size: 11px;
  font-weight: 700;
  color: #7c3aed;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

body.dark-mode #memories .memory-child-name { color: #a78bfa; }

#memories .memory-scope-extra {
  width: fit-content;
  border-radius: 999px;
  background: rgba(108,99,255,0.1);
  color: #6c63ff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
}

#memories .memory-date {
  font-size: 11.5px;
  color: #9ca3af;
  font-weight: 500;
}

/* Hide the category tag from body (shown as badge on image) */
#memories .memory-category-tag {
  display: none;
}

#memories .memory-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #1a1a2e;
  margin: 3px 0 0;
  line-height: 1.3;
}

body.dark-mode #memories .memory-title { color: #e5e7eb; }

#memories .memory-notes-preview {
  font-size: 12.5px;
  color: #6b7280;
  line-height: 1.45;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tag chips on card */
#memories .memory-tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

#memories .memory-tag-chip {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(108,99,255,0.08);
  color: #6c63ff;
  border: none;
  cursor: pointer;
  transition: background 0.12s;
}

#memories .memory-tag-chip:hover {
  background: rgba(108,99,255,0.16);
}

#memories .memory-tag-more {
  font-size: 10.5px;
  color: #9ca3af;
  font-weight: 600;
  align-self: center;
}

/* Card actions */
#memories .memory-card-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,0.05);
}

body.dark-mode #memories .memory-card-actions {
  border-top-color: rgba(255,255,255,0.06);
}

#memories .memory-card-actions .btn-secondary {
  flex: 1;
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid rgba(0,0,0,0.08);
  background: #f9fafb;
  color: #374151;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  font-family: inherit;
}

#memories .memory-card-actions .btn-secondary:hover {
  border-color: #6c63ff;
  color: #6c63ff;
  background: rgba(108,99,255,0.04);
}

/* File link (non-image) */
#memories .memory-file-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  min-height: 120px;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  color: #6c63ff;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.2s;
  border-radius: 0;
}

#memories .memory-file-link:hover {
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
}

/* ── Slideshow toolbar ────────────────────────────────────── */
#memories .memory-toolbar {
  margin-bottom: 14px;
}

#memories .memory-slideshow-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: 22px;
  background: linear-gradient(135deg, #6c63ff, #9b8bfb);
  border: none;
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(108,99,255,0.32);
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

#memories .memory-slideshow-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(108,99,255,0.42);
}

/* ── Premium empty state ─────────────────────────────────── */
#memories .memory-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 52px 24px;
  text-align: center;
}

.mem-empty-icon {
  font-size: 52px;
  opacity: 0.55;
  display: block;
}

.mem-empty-title {
  font-size: 18px;
  font-weight: 700;
  color: #374151;
  margin: 0;
  line-height: 1.2;
}

body.dark-mode .mem-empty-title { color: #d1d5db; }

.mem-empty-sub {
  font-size: 14px;
  color: #9ca3af;
  max-width: 320px;
  line-height: 1.5;
  margin: 0;
}

.mem-empty-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 24px;
  background: linear-gradient(135deg, #6c63ff, #9b8bfb);
  color: #fff;
  border: none;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(108,99,255,0.32);
  margin-top: 6px;
  font-family: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}

.mem-empty-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(108,99,255,0.42);
}

/* ── Lightbox polish ─────────────────────────────────────── */
#memories .memory-lightbox {
  background: rgba(10, 10, 20, 0.95);
}

#memories .memory-lightbox-content img {
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

#memories .memory-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.22);
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1;
}

#memories .memory-lightbox-close:hover {
  background: rgba(255,255,255,0.24);
}

#memories .memory-lightbox-prev,
#memories .memory-lightbox-next {
  background: rgba(255,255,255,0.14);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  color: #fff;
  transition: background 0.15s;
}

#memories .memory-lightbox-prev:hover,
#memories .memory-lightbox-next:hover {
  background: rgba(255,255,255,0.24);
}

/* ── Profile scope picker tweaks ─────────────────────────── */
#memories .memory-profile-scope-picker {
  padding-bottom: 10px;
  gap: 14px;
}

#memories .memory-profile-chip {
  flex-basis: 72px;
}

#memories .memory-profile-avatar {
  width: 52px;
  height: 52px;
  border-color: #c4b5fd;
  box-shadow: 0 3px 8px rgba(108,99,255,0.1);
}

#memories .memory-profile-chip.is-selected .memory-profile-avatar {
  border-color: #6c63ff;
  box-shadow: 0 0 0 4px rgba(108,99,255,0.2), 0 6px 16px rgba(108,99,255,0.18);
}

#memories .memory-profile-avatar--whole {
  background: linear-gradient(145deg, #7c3aed, #6c63ff);
}

#memories .memory-profile-check {
  background: #6c63ff;
}

#memories .memory-profile-scope-summary {
  border-color: #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
  color: #6b7280;
}

body.dark-mode #memories .memory-profile-scope-summary {
  background: #2a2a3e;
  border-color: rgba(255,255,255,0.1);
}

#memories .memory-profile-summary-count {
  color: #6c63ff;
  background: rgba(108,99,255,0.08);
  box-shadow: none;
}

/* Whole-family toggle (kept hidden — picker has the chip) */
.mem-whole-fam-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ── Scope info tooltip ───────────────────────────────────── */
#memories .memory-scope-info {
  border-color: #c4b5fd;
  color: #7c3aed;
}

/* ── Field-from-meta hints ───────────────────────────────── */
#memories .memory-field-from-meta {
  font-size: 11px;
  color: #6c63ff;
  opacity: 0.8;
}

/* ── Dark mode base ──────────────────────────────────────── */
body.dark-mode .mem-form-sub,
body.dark-mode .mem-gallery-sub { color: #9ca3af; }

body.dark-mode .mem-dropzone {
  border-color: rgba(108,99,255,0.3);
  background: rgba(108,99,255,0.05);
}

body.dark-mode .mem-dropzone:hover {
  border-color: #6c63ff;
  background: rgba(108,99,255,0.08);
}

body.dark-mode .mem-source-btn {
  background: #2a2a3e;
  border-color: rgba(255,255,255,0.1);
  color: #d1d5db;
}

body.dark-mode .mem-source-btn:hover {
  border-color: #6c63ff;
  color: #a78bfa;
}

body.dark-mode .mem-smart-fill {
  background: rgba(108,99,255,0.1);
  border-color: rgba(108,99,255,0.2);
}

body.dark-mode .mem-search-input,
body.dark-mode .mem-filter-select {
  background: #2a2a3e;
  border-color: rgba(255,255,255,0.1);
  color: #e5e7eb;
}

body.dark-mode .mem-clear-filters-btn {
  background: #2a2a3e;
  border-color: rgba(255,255,255,0.1);
  color: #9ca3af;
}

body.dark-mode .mem-group-title { color: #6b7280; }

body.dark-mode .memory-card-actions .btn-secondary {
  background: #2a2a3e;
  border-color: rgba(255,255,255,0.1);
  color: #d1d5db;
}

#memories .memory-photo-gallery-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 14, 45, 0.28);
  backdrop-filter: blur(8px);
}

#memories .memory-photo-gallery-backdrop[hidden] {
  display: none !important;
}

#memories .memory-photo-gallery-modal {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border-radius: 28px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(190, 170, 255, 0.34);
  box-shadow: 0 30px 80px rgba(35, 25, 80, 0.22);
  padding: 18px;
}

#memories .memory-photo-gallery-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

#memories .memory-photo-gallery-header h3 {
  margin: 0;
  color: #11184a;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.2;
}

#memories .memory-photo-gallery-header p {
  margin: 4px 0 0;
  color: #6d6f91;
  font-size: 13px;
}

#memories .memory-photo-gallery-close {
  display: grid;
  place-items: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: #f4efff;
  color: #6d3cf5;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

#memories .memory-photo-gallery-close:hover,
#memories .memory-photo-gallery-close:focus-visible {
  background: #ebe0ff;
  outline: none;
}

#memories .memory-photo-gallery-featured {
  margin-bottom: 12px;
  border-radius: 20px;
  overflow: hidden;
  background: #f7f1ff;
}

#memories .memory-photo-gallery-featured img {
  display: block;
  width: 100%;
  max-height: 360px;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  background: #11184a;
}

#memories .memory-photo-gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#memories .memory-photo-gallery-item {
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(190, 170, 255, 0.18);
}

#memories .memory-photo-gallery-item.is-selected,
#memories .memory-photo-gallery-item:focus-visible {
  box-shadow: 0 0 0 3px rgba(109, 60, 245, 0.24);
  outline: none;
}

#memories .memory-photo-gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 18px;
}

body.dark-mode #memories .memory-photo-gallery-modal {
  background: rgba(28, 28, 46, 0.96);
  border-color: rgba(255,255,255,0.12);
}

body.dark-mode #memories .memory-photo-gallery-header h3 {
  color: #f8fafc;
}

body.dark-mode #memories .memory-photo-gallery-header p {
  color: #c4b5fd;
}

@media (max-width: 640px) {
  #memories .memory-photo-gallery-backdrop {
    align-items: end;
    padding: 12px;
  }

  #memories .memory-photo-gallery-modal {
    width: 100%;
    max-height: 82vh;
    border-radius: 28px 28px 18px 18px;
  }
}
