/* ============================================================
   style.css — Family History Website Global Styles
   ============================================================ */

/* ── Custom Properties ─────────────────────────────────────── */
:root {
  --primary:        #1B3A6B;
  --primary-light:  #2C5AA0;
  --primary-dark:   #0F2340;
  --primary-glow:   rgba(27,58,107,0.15);
  --secondary:      #C8972B;
  --secondary-light:#E8B84B;
  --accent:         #2E7D52;
  --accent-light:   #3AA066;
  --danger:         #C0392B;
  --warning:        #E67E22;
  --info:           #2980B9;
  --bg:             #F4EFE8;
  --bg-alt:         #EDE8E0;
  --surface:        #FFFFFF;
  --surface-raised: #FDFBF8;
  --text:           #1A1A2A;
  --text-muted:     #6B7280;
  --text-light:     #9CA3AF;
  --border:         #E0D8CE;
  --border-focus:   #2C5AA0;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.06);
  --shadow-sm: 0 2px 8px rgba(27,58,107,.08);
  --shadow:    0 4px 20px rgba(27,58,107,.12);
  --shadow-lg: 0 8px 40px rgba(27,58,107,.18);
  --shadow-xl: 0 16px 60px rgba(27,58,107,.22);
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 22px;
  --radius-xl: 32px;
  --nav-w:     260px;
  --nav-w-c:   72px;
  --t:         .25s ease;
  --t-slow:    .45s ease;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  overflow-x: hidden;   /* iOS Safari requires this on html, not just body */
  max-width: 100vw;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
}
img { display: block; max-width: 100%; }
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
h1,h2,h3,h4,h5 { line-height: 1.3; font-weight: 700; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ── App Shell ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

/* ── Sidebar Nav ───────────────────────────────────────────── */
#app-nav {
  width: var(--nav-w);
  min-width: var(--nav-w);
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 8px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: width var(--t);
}
.nav-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 24px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: 8px;
}
.nav-logo { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.nav-brand-text { overflow: hidden; }
.nav-family { display: block; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .3px; }
.nav-tagline { font-size: 11px; opacity: .6; letter-spacing: .5px; text-transform: uppercase; }

.nav-family-switcher { padding: 0 8px 8px; }

.nav-add-family-btn {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  width: 100%; margin-top: 6px; padding: 7px 10px; box-sizing: border-box;
  font-size: 12px; font-weight: 700; color: rgba(255,255,255,.85); text-decoration: none;
  background: rgba(255,255,255,.1); border: none; border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}
.nav-add-family-btn:hover { background: rgba(255,255,255,.18); color: #fff; text-decoration: none; }

.nav-links { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.75); font-size: 14px; font-weight: 500;
  transition: all var(--t); position: relative; text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; transform: translateX(3px); }
.nav-link.active { background: rgba(255,255,255,.2); color: #fff; box-shadow: inset 3px 0 0 var(--secondary-light); }
.nav-icon { font-size: 18px; flex-shrink: 0; width: 24px; text-align: center; }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 99px; display: flex; align-items: center; justify-content: center;
  padding: 0 5px; margin-left: auto;
}

.nav-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 8px 4px;
  border-top: 1px solid rgba(255,255,255,.12);
  margin-top: 8px;
}
.nav-user-info { overflow: hidden; }
.nav-user-name { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-logout { font-size: 11px; color: rgba(255,255,255,.5); transition: color var(--t); }
.nav-logout:hover { color: var(--secondary-light); }
/* Logout nav link — hidden on desktop (sign out is in .nav-user), visible on mobile */
.nav-link-logout { display: none; }
/* Mobile top bar & overlay — hidden on desktop/tablet */
.mobile-topbar { display: none; }
.nav-hamburger { display: none; }
.nav-overlay   { display: none; }

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--nav-w);
  flex: 1;
  min-width: 0;
  max-width: calc(100vw - var(--nav-w));
  width: calc(100vw - var(--nav-w));
  padding: 32px;
  box-sizing: border-box;
  overflow-x: hidden;
  animation: fadeIn .35s cubic-bezier(.22,1,.36,1) both;
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px; flex-wrap: wrap; gap: 16px;
}
.page-title { font-size: 28px; font-weight: 800; color: var(--primary-dark); }
.page-title span { color: var(--secondary); }
.page-subtitle { color: var(--text-muted); font-size: 15px; margin-top: 4px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; border: none;
  cursor: pointer; transition: all var(--t); white-space: nowrap;
  text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px var(--primary-glow); }
.btn-primary:hover { background: var(--primary-light); box-shadow: 0 4px 16px var(--primary-glow); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary-light); color: var(--primary); background: var(--surface-raised); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-gold { background: linear-gradient(135deg, var(--secondary), var(--secondary-light)); color: #fff; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }
.btn-ghost { background: transparent; color: var(--text-muted); border: none; }
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow var(--t), transform var(--t);
  min-width: 0;
  max-width: 100%;
  width: 100%;
}
.card:hover { box-shadow: var(--shadow); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-header { padding: 20px 24px 0; }
.card-body { padding: 20px 24px; }
.card-footer { padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-raised); }
.card-title { font-size: 17px; font-weight: 700; color: var(--primary-dark); }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Stat Cards ─────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  transition: all var(--t);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-icon {
  width: 52px; height: 52px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.stat-icon-blue  { background: rgba(27,58,107,.1);  color: var(--primary); }
.stat-icon-gold  { background: rgba(200,151,43,.12); color: var(--secondary); }
.stat-icon-green { background: rgba(46,125,82,.1);  color: var(--accent); }
.stat-icon-red   { background: rgba(192,57,43,.1);  color: var(--danger); }
.stat-value { font-size: 28px; font-weight: 800; color: var(--primary-dark); line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ── Grid Layouts ───────────────────────────────────────────── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px)  { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px)  { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-label .required { color: var(--danger); }
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 14px;
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
}
.form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(44,90,160,.12); }
.form-control::placeholder { color: var(--text-light); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 540px) { .form-row { grid-template-columns: 1fr; } }

/* ── File Upload ────────────────────────────────────────────── */
.file-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t);
  position: relative;
}
.file-upload:hover, .file-upload.dragover { border-color: var(--primary-light); background: rgba(44,90,160,.04); }
.file-upload input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-upload-icon { font-size: 36px; margin-bottom: 10px; }
.file-upload-text { font-size: 14px; color: var(--text-muted); }
.file-upload-text strong { color: var(--primary-light); }

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%; object-fit: cover; flex-shrink: 0;
  border: 2px solid var(--border);
}
.avatar-placeholder {
  border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.avatar-lg { width: 80px !important; height: 80px !important; font-size: 30px !important; }
.avatar-xl { width: 120px !important; height: 120px !important; font-size: 44px !important; }

/* ── Badge / Chip ───────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 99px; font-size: 11px; font-weight: 600; letter-spacing: .3px;
}
.badge-blue   { background: rgba(27,58,107,.1);  color: var(--primary); }
.badge-gold   { background: rgba(200,151,43,.15); color: #8a6010; }
.badge-green  { background: rgba(46,125,82,.1);  color: var(--accent); }
.badge-red    { background: rgba(192,57,43,.1);  color: var(--danger); }
.badge-gray   { background: var(--bg-alt); color: var(--text-muted); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,19,32,.6);
  backdrop-filter: blur(4px); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; transition: opacity .25s;
}
.modal-overlay.show { opacity: 1; }
.modal-overlay.show .modal { transform: translateY(0) scale(1); }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px) scale(.97); transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px 18px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-header h3 { font-size: 19px; font-weight: 700; color: var(--primary-dark); }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--bg-alt); color: var(--text-muted); font-size: 18px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all var(--t); line-height: 1;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 24px 28px; }
.modal-footer {
  padding: 18px 28px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  background: var(--surface-raised);
  position: sticky; bottom: 0; z-index: 1;
}

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; align-items: center; gap: 10px;
  background: var(--primary-dark); color: #fff;
  padding: 12px 18px; border-radius: var(--radius);
  font-size: 14px; box-shadow: var(--shadow-lg);
  transform: translateY(20px); opacity: 0;
  transition: all .3s cubic-bezier(.34,1.56,.64,1);
  max-width: 380px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--accent); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--primary); }
.toast-warning { background: var(--warning); }
.toast-icon    { font-size: 16px; }

/* ── Tags Input ─────────────────────────────────────────────── */
.tags-container {
  display: flex; flex-wrap: wrap; gap: 6px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; background: var(--surface); min-height: 44px;
  cursor: text; transition: border-color var(--t);
}
.tags-container:focus-within { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(44,90,160,.12); }
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(27,58,107,.1); color: var(--primary);
  padding: 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 500;
}
.tag-chip button { background: none; border: none; color: inherit; font-size: 14px; line-height: 1; padding: 0; cursor: pointer; opacity: .6; }
.tag-chip button:hover { opacity: 1; }
.tags-input { border: none; outline: none; font-size: 13px; background: transparent; min-width: 80px; flex: 1; }

/* ── Photo Grid ─────────────────────────────────────────────── */
.photo-grid {
  columns: 4 220px; gap: 14px;
}
.photo-item {
  break-inside: avoid; margin-bottom: 14px;
  border-radius: var(--radius); overflow: hidden;
  position: relative; cursor: pointer;
  box-shadow: var(--shadow-xs);
}
.photo-item img {
  width: 100%; display: block;
  transition: transform .4s ease;
}
.photo-item:hover img { transform: scale(1.04); }
.photo-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.7) 0%, transparent 50%);
  opacity: 0; transition: opacity var(--t);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 14px;
}
.photo-item:hover .photo-overlay { opacity: 1; }
.photo-overlay-text { color: #fff; font-size: 12px; }
.photo-overlay-caption { font-weight: 600; font-size: 13px; }

/* ── Member Card ────────────────────────────────────────────── */
.member-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  transition: all var(--t); cursor: pointer;
  text-decoration: none; color: var(--text); display: block;
}
.member-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); text-decoration: none; }
.member-card-banner {
  height: 80px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  position: relative;
}
.member-card-banner-2 { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%); }
.member-card-banner-3 { background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%); }
.member-card-banner-4 { background: linear-gradient(135deg, #6B21A8 0%, #9333EA 100%); }
.member-card-banner-5 { background: linear-gradient(135deg, #0E7490 0%, #06B6D4 100%); }
.member-card-avatar {
  position: absolute; bottom: -24px; left: 50%; transform: translateX(-50%);
  width: 52px; height: 52px; border: 3px solid var(--surface);
  border-radius: 50%; object-fit: cover;
}
.member-card-body { padding: 32px 16px 18px; text-align: center; }
.member-card-name { font-size: 15px; font-weight: 700; color: var(--primary-dark); }
.member-card-rel { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.member-card-dates { font-size: 11px; color: var(--text-light); margin-top: 6px; }

/* ── Country Card ───────────────────────────────────────────── */
.country-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 20px;
  cursor: pointer; transition: all var(--t);
  display: flex; align-items: center; gap: 14px;
}
.country-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--primary-light); }
.country-flag { font-size: 36px; flex-shrink: 0; }
.country-info { flex: 1; min-width: 0; }
.country-name { font-size: 15px; font-weight: 700; color: var(--primary-dark); }
.country-count { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Story Card ─────────────────────────────────────────────── */
.story-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  transition: all var(--t); cursor: pointer;
}
.story-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.story-cover { height: 180px; object-fit: cover; width: 100%; background: linear-gradient(135deg, var(--primary), var(--primary-light)); display: flex; align-items: center; justify-content: center; font-size: 64px; }
.story-body { padding: 18px 20px; }
.story-title { font-size: 17px; font-weight: 700; color: var(--primary-dark); margin-bottom: 8px; }
.story-excerpt { font-size: 13px; color: var(--text-muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.story-meta { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--text-light); }

/* ── Timeline ───────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 24px; }
.timeline-dot { position: absolute; left: -24px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--secondary); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--secondary); }
.timeline-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.timeline-date { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.timeline-title { font-size: 15px; font-weight: 700; color: var(--primary-dark); }
.timeline-body { font-size: 14px; color: var(--text-muted); background: var(--surface-raised); padding: 14px 16px; border-radius: var(--radius-sm); border-left: 3px solid var(--border); white-space: pre-wrap; }

/* ── Tabs ───────────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 4px; border-bottom: 2px solid var(--border);
  margin-bottom: 24px; overflow-x: auto;
}
.tab-btn {
  padding: 10px 18px; border: none; background: transparent;
  color: var(--text-muted); font-size: 14px; font-weight: 600;
  cursor: pointer; position: relative; transition: color var(--t);
  white-space: nowrap; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab-btn::after {
  content: ''; position: absolute; bottom: -2px; left: 0; right: 0;
  height: 2px; background: var(--primary); transform: scaleX(0); transition: transform var(--t);
}
.tab-btn:hover { color: var(--primary); background: rgba(27,58,107,.04); }
.tab-btn.active { color: var(--primary); }
.tab-btn.active::after { transform: scaleX(1); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .3s ease; }

/* ── Lightbox ───────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.92);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.lightbox img { max-height: 80vh; max-width: 100%; border-radius: var(--radius); box-shadow: var(--shadow-xl); }
.lightbox-info { position: fixed; bottom: 0; left: 0; right: 0; background: linear-gradient(to top, rgba(0,0,0,.8), transparent); color: #fff; padding: 32px 24px 24px; }
.lightbox-close { position: fixed; top: 20px; right: 20px; background: rgba(255,255,255,.15); border: none; color: #fff; font-size: 24px; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; transition: background var(--t); display: flex; align-items: center; justify-content: center; }
.lightbox-close:hover { background: rgba(255,255,255,.25); }
.lightbox-nav { position: fixed; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.15); border: none; color: #fff; font-size: 22px; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; transition: background var(--t); display: flex; align-items: center; justify-content: center; }
.lightbox-nav:hover { background: rgba(255,255,255,.25); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 24px; color: var(--text-muted);
}
.empty-icon { font-size: 52px; margin-bottom: 16px; opacity: .6; }
.empty-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-text { font-size: 14px; max-width: 340px; margin: 0 auto 20px; }

/* ── Search / Filter Bar ────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  background: var(--surface); padding: 14px 18px; border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 24px; box-shadow: var(--shadow-xs);
}
.search-input {
  flex: 1; min-width: 180px; padding: 8px 14px 8px 38px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E") no-repeat 12px center;
  font-size: 14px; color: var(--text); outline: none; transition: border-color var(--t);
}
.search-input:focus { border-color: var(--primary-light); }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: none; } }
@keyframes slideUp { from { opacity:0; transform: translateY(24px); } to { opacity:1; transform: none; } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

.animate-in { animation: slideUp .4s cubic-bezier(.22,1,.36,1) both; }
.animate-in-2 { animation: slideUp .4s .08s cubic-bezier(.22,1,.36,1) both; }
.animate-in-3 { animation: slideUp .4s .16s cubic-bezier(.22,1,.36,1) both; }
.animate-in-4 { animation: slideUp .4s .24s cubic-bezier(.22,1,.36,1) both; }
.animate-in-5 { animation: slideUp .4s .32s cubic-bezier(.22,1,.36,1) both; }
.animate-in-6 { animation: slideUp .4s .40s cubic-bezier(.22,1,.36,1) both; }
.animate-in-7 { animation: slideUp .4s .48s cubic-bezier(.22,1,.36,1) both; }
.animate-in-8 { animation: slideUp .4s .56s cubic-bezier(.22,1,.36,1) both; }

/* ── Extended keyframes ──────────────────────────────────────────── */
@keyframes fadeInLeft    { from { opacity:0; transform:translateX(-26px); } to { opacity:1; transform:none; } }
@keyframes fadeInRight   { from { opacity:0; transform:translateX(26px);  } to { opacity:1; transform:none; } }
@keyframes scaleIn       { from { opacity:0; transform:scale(.91);         } to { opacity:1; transform:scale(1); } }
@keyframes popIn         { 0%  { opacity:0; transform:scale(.5); } 70% { transform:scale(1.1); } 100% { opacity:1; transform:scale(1); } }
@keyframes floatY        { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-7px); } }
@keyframes slideFromLeft { from { opacity:0; transform:translateX(-18px); } to { opacity:1; transform:none; } }
@keyframes breathe       { 0%,100% { box-shadow:0 0 0 0 rgba(44,90,160,0); } 55% { box-shadow:0 0 0 10px rgba(44,90,160,.12); } }
@keyframes navIn         { from { opacity:0; transform:translateX(-14px); } to { opacity:1; transform:none; } }

/* ── Page entrance ───────────────────────────────────────────────── */
/* Smooth fade-in for every app page */

/* ── Scroll reveal utility ───────────────────────────────────────── */
.sr       { opacity:0; transform:translateY(24px);  transition:opacity .55s cubic-bezier(.22,1,.36,1), transform .55s cubic-bezier(.22,1,.36,1); }
.sr-left  { opacity:0; transform:translateX(-20px); transition:opacity .55s cubic-bezier(.22,1,.36,1), transform .55s cubic-bezier(.22,1,.36,1); }
.sr-scale { opacity:0; transform:scale(.93);        transition:opacity .5s  cubic-bezier(.22,1,.36,1), transform .5s  cubic-bezier(.22,1,.36,1); }
.sr.in, .sr-left.in, .sr-scale.in { opacity:1; transform:none; }

/* ── Enhanced form focus glow ────────────────────────────────────── */
.form-control:focus { box-shadow: 0 0 0 3px rgba(44,90,160,.13); }

/* ── Button press feedback ───────────────────────────────────────── */
.btn-primary:active { transform:translateY(1px); box-shadow:0 0 0 4px rgba(44,90,160,.2); }
.btn-danger:active  { transform:translateY(1px); box-shadow:0 0 0 4px rgba(192,57,43,.18); }
.btn-ghost:active   { transform:translateY(1px); }

/* ── Nav link entrance stagger ───────────────────────────────────── */
.nav-links .nav-link { animation: navIn .3s cubic-bezier(.22,1,.36,1) both; }
.nav-links .nav-link:nth-child(1)  { animation-delay: .04s; }
.nav-links .nav-link:nth-child(2)  { animation-delay: .08s; }
.nav-links .nav-link:nth-child(3)  { animation-delay: .12s; }
.nav-links .nav-link:nth-child(4)  { animation-delay: .16s; }
.nav-links .nav-link:nth-child(5)  { animation-delay: .20s; }
.nav-links .nav-link:nth-child(6)  { animation-delay: .24s; }
.nav-links .nav-link:nth-child(7)  { animation-delay: .28s; }
.nav-links .nav-link:nth-child(8)  { animation-delay: .32s; }
.nav-links .nav-link:nth-child(9)  { animation-delay: .36s; }
.nav-links .nav-link:nth-child(10) { animation-delay: .40s; }

/* ── Active nav icon pulse ───────────────────────────────────────── */
.nav-link.active .nav-icon { animation: breathe 3s ease-in-out infinite; display:inline-flex; border-radius:8px; }

/* ── Stat card value pop ─────────────────────────────────────────── */
@keyframes statPop { 0% { opacity:0; transform:scale(.7) translateY(8px); } 70% { transform:scale(1.06); } 100% { opacity:1; transform:none; } }
.stat-card .stat-value { animation: statPop .5s cubic-bezier(.34,1.26,.64,1) both; }
.stat-card:nth-child(1) .stat-value { animation-delay:.06s; }
.stat-card:nth-child(2) .stat-value { animation-delay:.12s; }
.stat-card:nth-child(3) .stat-value { animation-delay:.18s; }
.stat-card:nth-child(4) .stat-value { animation-delay:.24s; }

/* ── Activity item slide in ──────────────────────────────────────── */
.activity-item { animation: slideFromLeft .4s cubic-bezier(.22,1,.36,1) both; }
.activity-item:nth-child(1)  { animation-delay:.05s; }
.activity-item:nth-child(2)  { animation-delay:.10s; }
.activity-item:nth-child(3)  { animation-delay:.15s; }
.activity-item:nth-child(4)  { animation-delay:.20s; }
.activity-item:nth-child(5)  { animation-delay:.25s; }
.activity-item:nth-child(6)  { animation-delay:.30s; }

/* ── Member avatar hover float ───────────────────────────────────── */
.member-card:hover .member-avatar { animation: floatY .7s ease-in-out; }

/* ── Badge scale on hover ────────────────────────────────────────── */
.badge { transition: transform var(--t), background var(--t); }
.badge:hover { transform: scale(1.08); }

/* ── Auth page entrance animations ──────────────────────────────── */
@keyframes authCardIn { from { opacity:0; transform:translateY(36px) scale(.97); } to { opacity:1; transform:none; } }
.auth-card            { animation: authCardIn .55s cubic-bezier(.22,1,.36,1) both; }
.auth-logo            { animation: popIn .65s .15s cubic-bezier(.34,1.56,.64,1) both; }
.auth-title           { animation: slideUp .4s .25s cubic-bezier(.22,1,.36,1) both; }
.auth-subtitle        { animation: slideUp .4s .32s cubic-bezier(.22,1,.36,1) both; }
.auth-card-body       { animation: slideUp .4s .20s cubic-bezier(.22,1,.36,1) both; }

/* ── Photo item reveal ───────────────────────────────────────────── */
.photo-grid-item { animation: scaleIn .4s cubic-bezier(.22,1,.36,1) both; }

/* ── Page header reveal ──────────────────────────────────────────── */
.page-header { animation: slideUp .4s cubic-bezier(.22,1,.36,1) both; }

/* ── Card hover lift enhancement ─────────────────────────────────── */
.doc-card:hover, .story-card:hover, .country-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}
.doc-card, .story-card, .country-card {
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}

/* ── Modal backdrop blur entrance ────────────────────────────────── */
.modal-overlay { transition: opacity .25s, backdrop-filter .25s; }
.modal-overlay.show { backdrop-filter: blur(6px); }

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-alt) 50%, var(--border) 75%);
  background-size: 400px 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm);
}

/* ── Section Headers ────────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.section-title { font-size: 19px; font-weight: 700; color: var(--primary-dark); display: flex; align-items: center; gap: 8px; }
.section-title .icon { font-size: 20px; }

/* ── Profile Header ─────────────────────────────────────────── */
.profile-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  border-radius: var(--radius-lg); padding: 36px 36px 0; color: #fff;
  margin-bottom: 32px; position: relative; overflow: hidden;
}
.profile-header::before {
  content: ''; position: absolute; top: -40%; right: -10%; width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,.08) 0%, transparent 70%);
}
.profile-header-inner { position: relative; display: flex; gap: 28px; align-items: flex-end; flex-wrap: wrap; }
.profile-avatar-wrap { flex-shrink: 0; padding-bottom: 28px; }
.profile-avatar {
  width: 110px; height: 110px; border-radius: 50%; object-fit: cover;
  border: 4px solid rgba(255,255,255,.4);
  background: rgba(255,255,255,.2); font-size: 42px; color: rgba(255,255,255,.9);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.profile-info { flex: 1; padding-bottom: 28px; }
.profile-name { font-size: 30px; font-weight: 800; margin-bottom: 6px; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 18px; font-size: 14px; opacity: .85; }
.profile-meta-item { display: flex; align-items: center; gap: 6px; }
.profile-tabs { display: flex; gap: 4px; margin-top: 20px; overflow-x: auto; scrollbar-width: none; }
.profile-tabs::-webkit-scrollbar { display: none; }
.profile-tab {
  padding: 10px 20px; border: none; background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.75); cursor: pointer; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 13px; font-weight: 600; transition: all var(--t);
}
.profile-tab:hover { background: rgba(255,255,255,.2); color: #fff; }
.profile-tab.active { background: var(--surface); color: var(--primary-dark); }

/* ── Login Page ─────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, #1e4080 40%, #2a5298 70%, var(--primary-light) 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  position: relative; overflow: hidden;
}
.auth-bg-shapes { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.auth-bg-circle {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.06) 0%, transparent 70%);
  animation: pulse 6s ease-in-out infinite;
}
.auth-bg-circle:nth-child(1) { width: 600px; height: 600px; top: -200px; right: -100px; }
.auth-bg-circle:nth-child(2) { width: 400px; height: 400px; bottom: -150px; left: -100px; animation-delay: -3s; }
.auth-bg-circle:nth-child(3) { width: 300px; height: 300px; top: 30%; left: 20%; animation-delay: -1.5s; opacity: .5; }
.auth-wrap { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 460px; }
.auth-card {
  background: var(--surface); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl); width: 100%; max-width: 460px;
  overflow: hidden;
}
.auth-card-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  padding: 36px 36px 28px; color: #fff; text-align: center;
}
.auth-logo { width: 64px; height: 64px; object-fit: contain; margin-bottom: 12px; display: block; margin-left: auto; margin-right: auto; }
.auth-title { font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.auth-subtitle { opacity: .8; font-size: 14px; }
.auth-card-body { padding: 32px 36px; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 28px; background: var(--bg-alt); border-radius: var(--radius-sm); padding: 4px; }
.auth-tab {
  flex: 1; padding: 8px; border: none; background: transparent;
  font-size: 14px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; border-radius: 8px; transition: all var(--t);
}
.auth-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); }

/* ── Dashboard Welcome Banner ───────────────────────────────── */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  border-radius: var(--radius-lg); padding: 32px 36px; color: #fff;
  margin-bottom: 28px; display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap; position: relative; overflow: hidden;
}
.welcome-banner::after {
  content: '🌳'; position: absolute; right: 20px; bottom: -10px;
  font-size: 100px; opacity: .12; line-height: 1;
}
.welcome-title { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.welcome-sub { opacity: .8; font-size: 15px; }

/* ── Bio Section ────────────────────────────────────────────── */
.bio-section {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 24px;
  box-shadow: var(--shadow-sm);
}
.bio-text { color: var(--text-muted); font-size: 15px; line-height: 1.8; white-space: pre-wrap; }
.bio-placeholder { color: var(--text-light); font-style: italic; }

/* ── Recent Photos Strip ────────────────────────────────────── */
.photo-strip {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px;
}
.photo-strip-item {
  flex-shrink: 0; width: 120px; height: 90px; border-radius: var(--radius-sm);
  overflow: hidden; cursor: pointer; position: relative;
  box-shadow: var(--shadow-xs);
}
.photo-strip-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.photo-strip-item:hover img { transform: scale(1.08); }

/* ── Member List Table ──────────────────────────────────────── */
.member-list { width: 100%; border-collapse: collapse; }
.member-list th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; padding: 10px 14px; border-bottom: 2px solid var(--border); background: var(--surface-raised); }
.member-list td { padding: 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.member-list tr:last-child td { border-bottom: none; }
.member-list tr:hover td { background: rgba(27,58,107,.03); }
.member-list-name { display: flex; align-items: center; gap: 10px; }

/* ── Section Divider ────────────────────────────────────────── */
.section-divider { height: 1px; background: var(--border); margin: 24px 0; }

/* ── Responsive — Tablet (≤ 768px) ─────────────────────────── */
@media (max-width: 768px) {
  #app-nav { width: var(--nav-w-c); padding: 16px 10px; }
  .nav-label, .nav-brand-text, .nav-user-info, .nav-family-switcher { display: none; }
  .nav-brand { justify-content: center; padding: 8px 0 20px; }
  .nav-link { justify-content: center; padding: 12px; }
  .main-content { margin-left: var(--nav-w-c); padding: 20px 16px; }
  .modal { max-width: 100%; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .page-title { font-size: 22px; }
  .profile-name { font-size: 24px; }
  .welcome-title { font-size: 20px; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ── Responsive — Mobile Phone (≤ 600px) ────────────────────── */
@media (max-width: 600px) {

  /* ══ DRAWER NAV ══════════════════════════════════════════════ */
  #app-nav {
    width: var(--nav-w) !important;
    min-width: var(--nav-w) !important;
    height: 100%;
    position: fixed;
    top: 0; left: 0; bottom: 0; right: auto;
    flex-direction: column;
    padding: 24px 16px;
    gap: 8px;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 500;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  }
  #app-nav.nav-open { transform: translateX(0); box-shadow: 4px 0 32px rgba(0,0,0,.4); }

  .nav-brand            { display: flex !important; padding: 8px 8px 24px; justify-content: flex-start; }
  .nav-brand-text       { display: block !important; }
  .nav-user             { display: flex !important; }
  .nav-user-info        { display: block !important; }
  .nav-family-switcher  { display: block !important; }
  .nav-links            { flex-direction: column; gap: 4px; overflow: visible; }
  .nav-label            { display: block !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nav-link {
    flex-direction: row !important; gap: 12px !important; padding: 11px 14px !important;
    justify-content: flex-start !important; align-items: center !important;
    font-size: 14px !important; font-weight: 500 !important;
    border-radius: var(--radius-sm) !important; min-width: 0 !important; flex: none !important;
  }
  .nav-link:hover  { background: rgba(255,255,255,.12); color: #fff; transform: translateX(3px); }
  .nav-link.active { background: rgba(255,255,255,.2);  color: #fff; box-shadow: inset 3px 0 0 var(--secondary-light); }
  .nav-icon  { font-size: 18px; width: 24px; text-align: center; }
  .nav-badge { position: static; margin-left: auto; min-width: 18px; height: 18px; font-size: 10px; }
  .nav-link-logout { display: none; }

  .nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.52); backdrop-filter: blur(2px); z-index: 499; }
  .nav-overlay.show { display: block; }

  /* ══ MOBILE TOP BAR ══════════════════════════════════════════ */
  .mobile-topbar {
    display: flex; align-items: center;
    position: fixed; top: 0; left: 0; right: 0;
    height: 52px; z-index: 400;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 6px rgba(27,58,107,.07);
    padding: 0 8px; gap: 10px;
  }
  .mobile-topbar-title {
    flex: 1; font-size: 16px; font-weight: 800; color: var(--primary-dark);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.2px;
  }
  .nav-hamburger {
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-dark); color: #fff; border: none;
    border-radius: var(--radius-sm); width: 40px; height: 40px;
    font-size: 19px; cursor: pointer; transition: background var(--t);
    line-height: 1; flex-shrink: 0;
  }
  .nav-hamburger:hover { background: var(--primary); }

  /* ══ MAIN CONTENT ════════════════════════════════════════════ */
  .main-content {
    margin-left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    padding: 60px 16px 32px !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  /* ══ PAGE HEADER ═════════════════════════════════════════════ */
  /* Title is in the top bar — hide it here, keep action buttons */
  .page-header .page-title,
  .page-header .page-subtitle { display: none; }
  .page-header { margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }
  /* Action buttons in page-header get proper tap targets */
  .page-header .btn { min-height: 40px; }

  /* ══ GRIDS ═══════════════════════════════════════════════════ */
  .grid-2 { grid-template-columns: 1fr; gap: 10px; }
  .grid-3 { grid-template-columns: 1fr; gap: 10px; }
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* ══ STAT CARDS ══════════════════════════════════════════════ */
  .stat-card  { padding: 12px 14px; gap: 10px; }
  .stat-icon  { width: 36px; height: 36px; font-size: 16px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 11px; }

  /* ══ SECTION HEADERS ═════════════════════════════════════════ */
  /* Stack label + action button vertically */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 10px;
  }
  .section-title      { font-size: 13px; gap: 5px; }
  .section-title .icon { font-size: 14px; }

  /* ══ BUTTONS ═════════════════════════════════════════════════ */
  .btn    { padding: 12px 18px; font-size: 14px; min-height: 44px; }
  .btn-sm { padding: 8px 14px;  font-size: 13px; min-height: 38px; }
  .btn-lg { padding: 14px 24px; font-size: 15px; }

  /* ══ FORMS ═══════════════════════════════════════════════════ */
  .form-control { padding: 12px 14px; font-size: 16px; } /* 16px stops iOS auto-zoom */
  .form-row     { grid-template-columns: 1fr; }
  .form-group   { margin-bottom: 14px; }

  /* ══ CARDS ═══════════════════════════════════════════════════ */
  .card        { border-radius: var(--radius); }
  .card-header { padding: 12px 14px; }
  .card-body   { padding: 14px; }
  .card-footer { padding: 10px 14px; }

  /* ══ FILTER BAR ══════════════════════════════════════════════ */
  /* Stack search above filter chips */
  .filter-bar   { flex-direction: column; padding: 10px 16px; gap: 8px; align-items: stretch; }
  .search-input { width: 100%; font-size: 15px; }
  /* Chips scroll horizontally in a single row */
  .filter-chips, .filter-bar > div:not(:first-child) {
    display: flex; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 6px; padding-bottom: 2px;
    scrollbar-width: none;
  }
  .filter-chips::-webkit-scrollbar,
  .filter-bar > div:not(:first-child)::-webkit-scrollbar { display: none; }

  /* ══ TABS ════════════════════════════════════════════════════ */
  .tabs, .tab-list { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar, .tab-list::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 8px 14px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }

  /* ══ MODALS ══════════════════════════════════════════════════ */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal         { max-width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; }
  .modal-header  { padding: 18px 20px 14px; }
  .modal-body    { padding: 16px 20px; }
  .modal-footer  { padding: 14px 20px; }

  /* ══ PROFILE ═════════════════════════════════════════════════ */
  .profile-header       { padding: 20px 16px 0; border-radius: var(--radius); }
  .profile-header-inner { flex-direction: column; align-items: center; text-align: center; gap: 14px; }
  .profile-info         { padding-bottom: 0; width: 100%; }
  .profile-name         { font-size: 20px; }
  .profile-meta         { justify-content: center; gap: 10px; font-size: 12px; flex-wrap: wrap; }
  .profile-tabs         { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; -ms-overflow-style: none; padding-bottom: 0; gap: 2px; }
  .profile-tabs::-webkit-scrollbar { display: none; }
  .profile-tab          { padding: 8px 12px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
  .profile-avatar       { width: 80px !important; height: 80px !important; font-size: 30px !important; }
  .profile-avatar-wrap  { padding-bottom: 0; }
  .profile-name-row     { flex-direction: column; gap: 8px; }
  .profile-header-actions { justify-content: center; }

  /* ══ MEMBER CARDS ════════════════════════════════════════════ */
  .member-card-body { padding: 24px 12px 12px; }
  .member-card-name { font-size: 13px; }

  /* ══ WELCOME BANNER ══════════════════════════════════════════ */
  .welcome-banner { padding: 20px 16px; gap: 12px; }
  .welcome-banner::after { display: none; }
  .welcome-title  { font-size: 18px; }
  .welcome-sub    { font-size: 13px; }

  /* ══ AUTH ════════════════════════════════════════════════════ */
  .auth-card-header { padding: 24px 20px 18px; }
  .auth-card-body   { padding: 20px; }
  .auth-title       { font-size: 22px; }
  .auth-logo        { width: 48px; height: 48px; }

  /* ══ TOAST ═══════════════════════════════════════════════════ */
  .toast { bottom: 20px; left: 14px; right: 14px; max-width: none; text-align: center; justify-content: center; }

  /* ══ PHOTOS ══════════════════════════════════════════════════ */
  .photo-grid { columns: 2 120px; gap: 8px; }
  .photo-item { margin-bottom: 8px; }

  /* ══ DASHBOARD ═══════════════════════════════════════════════ */
  .dash-main-grid { gap: 12px !important; }
  .dash-main-grid > div { gap: 12px !important; }
  #stats-row { margin-bottom: 16px !important; }

  /* ══ BIO TEXT ════════════════════════════════════════════════ */
  .bio-text {
    font-size: 13px !important; line-height: 1.6 !important;
    display: -webkit-box; -webkit-line-clamp: 4;
    -webkit-box-orient: vertical; overflow: hidden;
  }
  .bio-text.expanded { display: block; overflow: visible; -webkit-line-clamp: unset; }
  .bio-read-more { font-size: 12px; color: var(--primary-light); background: none; border: none; padding: 4px 0 0; cursor: pointer; display: block; }

  /* ══ ACTIVITY FEED ═══════════════════════════════════════════ */
  .activity-item { gap: 8px; padding: 8px 0; }
  .activity-icon { width: 28px; height: 28px; font-size: 13px; flex-shrink: 0; }
  .activity-body { flex: 1; min-width: 0; }
  .activity-text { font-size: 12px; word-break: break-word; overflow-wrap: break-word; }
  .activity-time { font-size: 10px; }

  /* ══ TIMELINE ════════════════════════════════════════════════ */
  .timeline      { padding-left: 20px; }
  .timeline-item { padding: 8px 0 8px 16px; }
  .timeline-dot  { width: 10px; height: 10px; left: -5px; }

  /* ══ TREE & MAP TOOLBARS ═════════════════════════════════════ */
  .tree-toolbar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .tree-toolbar .btn { padding: 7px 12px; font-size: 12px; min-height: 36px; }
  .map-toolbar  { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .map-stat     { padding: 4px 10px; font-size: 12px; }

  /* ══ ADMIN ═══════════════════════════════════════════════════ */
  .admin-section-body   { padding: 16px; }
  .admin-section-header { padding: 14px 16px; }
  .join-code-display    { font-size: 22px; letter-spacing: 5px; padding: 12px 16px; }
  .member-manage        { flex-wrap: wrap; gap: 8px; }

  /* ══ LIGHTBOX ════════════════════════════════════════════════ */
  .lightbox-nav   { width: 44px; height: 44px; }
  .lightbox-close { width: 44px; height: 44px; }
  .lightbox-info  { padding: 16px 16px 28px; max-height: 46vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* ══ PAGE CARD HEADERS (diary-day, document-view) ════════════ */
  /* Wrap buttons to a second line so they don't spill outside the card */
  .page-card-header { flex-wrap: wrap; padding: 10px 14px; gap: 6px; }
  .page-card-header > div { margin-left: 0 !important; width: 100%; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

  /* ══ DIARY / DOCUMENT HEADER BUTTONS ════════════════════════ */
  .diary-header   > div { flex-direction: column !important; align-items: flex-start !important; }
  .doc-header-bar .doc-title-row { flex-direction: column; }
}


/* ── Small phones (≤ 400px) ─────────────────────────────────── */
@media (max-width: 400px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-title { font-size: 18px; }
  .nav-label { display: block !important; } /* keep labels visible in the slide-in drawer */
  .photo-grid { columns: 1; }
  /* Stats go single column on very small phones */
  #stats-row { grid-template-columns: 1fr 1fr !important; }
  .stat-value { font-size: 18px; }
}

@media (max-width: 480px) {
  .auth-card-header { padding: 28px 24px 20px; }
  .auth-card-body { padding: 24px; }
}

/* ── Utility ─────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Loading Overlay ─────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(15,23,64,.55);
  backdrop-filter: blur(6px); z-index: 9000;
  display: flex; align-items: center; justify-content: center;
}
.loading-spinner-wrap {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 36px 48px; text-align: center; box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.loading-spinner {
  width: 48px; height: 48px; border: 4px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
.loading-msg { font-size: 15px; font-weight: 600; color: var(--primary-dark); }

/* ── OCR / Text Extraction Widget ────────────────────────────── */
.ocr-widget {
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-top: 12px;
}
.ocr-progress-bar { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.ocr-progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light)); border-radius: 99px; transition: width .3s ease; }
.ocr-text-result {
  background: #FFFEF7; border: 1px solid #E8DFC0; border-radius: var(--radius-sm);
  padding: 12px 14px; margin-top: 10px; font-size: 13px; line-height: 1.8;
  color: var(--text); white-space: pre-wrap; max-height: 200px; overflow-y: auto;
  font-family: Georgia, serif;
}
.ocr-translation-result {
  background: rgba(27,58,107,.04); border: 1px solid rgba(27,58,107,.15); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-top: 8px; font-size: 13px; line-height: 1.8;
  color: var(--text); white-space: pre-wrap; max-height: 200px; overflow-y: auto;
}
.lang-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(46,125,82,.1); color: var(--accent);
  padding: 2px 10px; border-radius: 99px; font-size: 11px; font-weight: 600;
}

/* ── Family Tree ─────────────────────────────────────────────── */
.tree-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.tree-toolbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 20px; display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; z-index: 10; box-shadow: var(--shadow-xs); flex-shrink: 0;
}
.tree-viewport {
  flex: 1; overflow: hidden; position: relative; background: var(--bg);
  cursor: grab; user-select: none;
}
.tree-viewport.dragging { cursor: grabbing; }
.tree-canvas {
  position: absolute; transform-origin: 0 0;
  will-change: transform;
}
.tree-node {
  position: absolute; width: 160px;
  transform: translate(-50%, -50%);
}
.tree-node-card {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 12px; text-align: center;
  box-shadow: var(--shadow-sm); transition: all var(--t); cursor: pointer;
  position: relative;
}
.tree-node-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow); transform: translateY(-2px); }
.tree-node-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27,58,107,.15); }
.tree-node-card.highlight-focus { border-color: var(--secondary); background: rgba(200,151,43,.06); }
.tree-node-avatar {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 8px;
  object-fit: cover; border: 2px solid var(--border);
}
.tree-node-avatar-placeholder {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 700;
}
.tree-node-name { font-size: 13px; font-weight: 700; color: var(--primary-dark); line-height: 1.3; }
.tree-node-dates { font-size: 10px; color: var(--text-muted); margin-top: 3px; }
.tree-node-rel { font-size: 10px; color: var(--text-light); }
.tree-node-deceased .tree-node-card { opacity: .8; }
.tree-node-deceased .tree-node-name::after { content: ' ✝'; color: var(--text-light); font-size: 10px; }
.tree-svg { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.tree-connector { fill: none; stroke: var(--border); stroke-width: 2; }
.tree-connector-spouse { stroke: var(--secondary); stroke-dasharray: 6 3; stroke-width: 1.5; }
.tree-zoom-controls {
  position: absolute; bottom: 20px; right: 20px; z-index: 20;
  display: flex; flex-direction: column; gap: 4px;
}
.tree-zoom-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  font-size: 18px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; box-shadow: var(--shadow-sm); transition: all var(--t);
  color: var(--primary-dark);
}
.tree-zoom-btn:hover { background: var(--bg-alt); }
.tree-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.tree-legend {
  position: absolute; bottom: 20px; left: 20px; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 12px; box-shadow: var(--shadow-sm);
}
.tree-legend-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; color: var(--text-muted); }
.tree-legend-line { width: 28px; height: 2px; }

/* ── Member-mini alignment fix ───────────────────────────────── */
.member-mini {
  flex-shrink: 0; text-align: center; cursor: pointer; width: 80px;
  text-decoration: none; display: flex; flex-direction: column; align-items: center;
}
.member-mini:hover .member-mini-name { color: var(--primary); text-decoration: none; }
.member-mini-name {
  font-size: 11px; color: var(--text-muted); margin-top: 5px;
  width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: center;
}

/* ══════════════════════════════════════════════════════════════════════
   ENHANCED AESTHETICS & ANIMATIONS
   ══════════════════════════════════════════════════════════════════════ */

/* ── Warm ambient body glow ──────────────────────────────────────────── */
body {
  background-image:
    radial-gradient(ellipse at 15% 8%,  rgba(200,151,43,.055) 0%, transparent 40%),
    radial-gradient(ellipse at 85% 92%, rgba(27,58,107,.055)  0%, transparent 40%);
}

/* ── Gradient page titles ────────────────────────────────────────────── */
.page-title {
  background: linear-gradient(135deg, var(--primary-dark) 10%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-title > span {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Card positioning for shine ──────────────────────────────────────── */
.card         { position: relative; }
.stat-card    { position: relative; overflow: hidden; }
.member-card  { position: relative; }
.story-card   { position: relative; }
.country-card { position: relative; overflow: hidden; }

/* ── Card hover shine sweep ──────────────────────────────────────────── */
@keyframes cardShine {
  from { transform: translateX(-200%) skewX(-18deg); }
  to   { transform: translateX(400%)  skewX(-18deg); }
}
.card::after,
.stat-card::after,
.member-card::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 50%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.2), transparent);
  transform: translateX(-200%) skewX(-18deg);
  pointer-events: none;
  border-radius: inherit;
}
.card:hover::after,
.stat-card:hover::after,
.member-card:hover::after {
  animation: cardShine .6s ease forwards;
}

/* ── Enhanced button glows ───────────────────────────────────────────── */
.btn { overflow: hidden; }
.btn-primary:hover {
  box-shadow: 0 6px 22px rgba(27,58,107,.4), 0 0 0 4px rgba(27,58,107,.08);
}
.btn-gold:hover {
  box-shadow: 0 6px 22px rgba(200,151,43,.38), 0 0 0 3px rgba(200,151,43,.1);
}
.btn-danger:hover {
  box-shadow: 0 6px 18px rgba(192,57,43,.35), 0 0 0 3px rgba(192,57,43,.08);
}
.btn-accent:hover {
  box-shadow: 0 6px 18px rgba(46,125,82,.35), 0 0 0 3px rgba(46,125,82,.08);
}

/* ── Button ripple ───────────────────────────────────────────────────── */
@keyframes btnRipple {
  from { transform: scale(0); opacity: .45; }
  to   { transform: scale(1); opacity: 0;  }
}
.btn-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.45);
  animation: btnRipple .55s ease-out forwards;
  pointer-events: none;
}

/* ── Welcome banner shimmer overlay ─────────────────────────────────── */
@keyframes bannerShimmer {
  0%   { transform: translateX(-150%) rotate(14deg); }
  100% { transform: translateX(350%)  rotate(14deg); }
}
.welcome-banner::before {
  content: '';
  position: absolute; inset: 0; width: 35%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent);
  animation: bannerShimmer 5s ease-in-out infinite;
  pointer-events: none;
}

/* ── Profile avatar glow ring ────────────────────────────────────────── */
@keyframes avatarRingGlow {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255,255,255,.25), 0 0 14px rgba(255,255,255,.1); }
  50%       { box-shadow: 0 0 0 7px rgba(255,255,255,.38), 0 0 24px rgba(255,255,255,.22); }
}
.profile-avatar { animation: avatarRingGlow 4s ease-in-out infinite; }

/* ── Empty state icon float ──────────────────────────────────────────── */
@keyframes iconFloat {
  0%, 100% { transform: translateY(0)     scale(1);    }
  50%       { transform: translateY(-10px) scale(1.06); }
}
.empty-icon      { animation: iconFloat 3.2s ease-in-out infinite; }
.chat-empty-icon { animation: iconFloat 3.2s ease-in-out infinite; }

/* ── Timeline dot pulse ──────────────────────────────────────────────── */
@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--secondary), 0 0 0 4px transparent;         }
  50%       { box-shadow: 0 0 0 2px var(--secondary), 0 0 0 6px rgba(200,151,43,.22); }
}
.timeline-dot { animation: dotPulse 2.8s ease-in-out infinite; }

/* ── Country flag bounce on card hover ───────────────────────────────── */
@keyframes flagBounce {
  0%   { transform: scale(1)    rotate(0deg);  }
  25%  { transform: scale(1.28) rotate(-8deg); }
  60%  { transform: scale(1.18) rotate(5deg);  }
  100% { transform: scale(1)    rotate(0deg);  }
}
.country-card:hover .country-flag {
  animation: flagBounce .5s ease;
  display: inline-block;
}

/* ── Stat icon pop on hover ──────────────────────────────────────────── */
.stat-icon { transition: transform var(--t); }
.stat-card:hover .stat-icon {
  transform: scale(1.14) rotate(-4deg);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}

/* ── Member card avatar lift on hover ────────────────────────────────── */
.member-card-avatar { transition: transform var(--t); }
.member-card:hover .member-card-avatar {
  transform: translateX(-50%) translateY(-6px);
  transition: transform .3s cubic-bezier(.34,1.26,.64,1);
}

/* ── Photo hover glow ────────────────────────────────────────────────── */
.photo-item:hover { box-shadow: 0 8px 30px rgba(27,58,107,.22); }
.photo-item img   { transition: transform .4s ease; }
.photo-item:hover img { transform: scale(1.05); }

/* ── Nav badge pop ───────────────────────────────────────────────────── */
@keyframes badgePop {
  0%   { opacity: 0; transform: scale(.4)  translateY(4px);  }
  70%  {             transform: scale(1.15) translateY(-2px); }
  100% { opacity: 1; transform: scale(1)   translateY(0);    }
}
.nav-badge         { animation: badgePop .4s .3s cubic-bezier(.34,1.56,.64,1) both; }
.chat-unread-badge { animation: badgePop .4s    cubic-bezier(.34,1.56,.64,1) both; }

/* ── Active nav link depth shadow ────────────────────────────────────── */
.nav-link.active {
  box-shadow: inset 3px 0 0 var(--secondary-light), 0 2px 12px rgba(0,0,0,.18);
}

/* ── Tree node card depth on hover ───────────────────────────────────── */
.tree-node-card:hover {
  box-shadow: var(--shadow), 0 0 0 3px rgba(27,58,107,.1);
}

/* ── Dual-colour loading spinner ─────────────────────────────────────── */
.loading-spinner {
  border-color: rgba(27,58,107,.12);
  border-top-color: var(--primary);
  border-right-color: var(--secondary);
}

/* ── File upload hover elevation ─────────────────────────────────────── */
.file-upload:hover  { box-shadow: 0 0 0 4px rgba(44,90,160,.08); }
.file-upload.dragover {
  box-shadow: 0 0 0 6px rgba(44,90,160,.14);
  transform: scale(1.015);
  transition: all .2s ease;
}

/* ── Form control focus elevation ────────────────────────────────────── */
.form-control:focus {
  box-shadow: 0 4px 14px rgba(44,90,160,.12), 0 0 0 3px rgba(44,90,160,.13);
}

/* ── Scrollbar accent ────────────────────────────────────────────────── */
::-webkit-scrollbar-thumb       { background: rgba(27,58,107,.2);  }
::-webkit-scrollbar-thumb:hover { background: rgba(27,58,107,.38); }

/* ── Story card cover zoom on hover ──────────────────────────────────── */
.story-card .story-cover img { transition: transform .45s ease; }
.story-card:hover .story-cover img { transform: scale(1.06); }

/* ── Doc card hover accent border ────────────────────────────────────── */
.doc-card:hover { border-color: var(--primary-light); }

/* ── Skeleton shimmer (richer gradient) ──────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--border) 0%, #f5efea 45%, #fffdf9 55%, var(--border) 100%
  );
  background-size: 600px 100%;
}

/* ── Mobile: prevent iOS focus zoom ─────────────────────────────
   iOS Safari zooms the whole page when a focused form field has a
   font-size under 16px. Enforce 16px on phone-width screens so
   typing anywhere (chat, captions, forms) never triggers the zoom. */
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px !important; }
}
