/* ── CSS Variables (light mode defaults) ──────────────────────────────────── */
:root {
  --bg:          #c4c7cc;
  --surface:     #fff;
  --surface-2:   #f7f6f4;
  --surface-3:   #f3f2f0;
  --border:      #ebe8e4;
  --border-2:    #e0ddd8;
  --text:        #444;
  --text-2:      #555;
  --text-3:      #777;
  --text-muted:  #888;
  --text-faint:  #aaa;
  --text-ghost:  #bbb;
  --input-bg:    #f7f6f4;
  --shadow:      rgba(0,0,0,.07);
}


/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  background: #fff;
  color: #595959;
  border-bottom: 2px solid #2e2e2e;
  position: sticky; top: 0; z-index: 1000;
}
.header-inner {
  max-width: 100%; margin: 0;
  display: flex; align-items: center; gap: 0;
  padding: 0 15px; height: 46px;
}
.logo {
  display: flex; align-items: center; gap: 7px;
  color: #595959; flex-shrink: 0; text-decoration: none; margin-right: 24px;
}
.logo-icon { width: 20px; height: 20px; }
.logo-text {
  font-size: 15px; font-weight: 400;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: #595959; letter-spacing: normal; white-space: nowrap;
}
/* Search sits right after logo */
.header-search { display: flex; align-items: center; margin-right: 20px; flex-shrink: 0; }
.header-search-wrap { position: relative; display: flex; align-items: center; }
.header-search-icon {
  position: absolute; left: 9px; width: 12px; height: 12px;
  color: #bbb; pointer-events: none; flex-shrink: 0;
}
.header-search-input {
  width: 170px; padding: 5px 12px 5px 27px; border-radius: 14px;
  border: 1.5px solid #e2e2e2; font-size: 12px; outline: none;
  background: #f7f7f7; color: #444; transition: border-color .15s, background .15s;
}
.header-search-input::placeholder { color: #bbb; }
.header-search-input:focus { background: #fff; border-color: #bbb; }
/* Nav links */
.main-nav { display: flex; align-items: stretch; gap: 0; height: 46px; flex: 1; }
.nav-link {
  color: #595959;
  padding: 0;
  min-width: 72px;
  font-size: 14px; font-weight: 400;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: normal; line-height: 1;
  transition: color .12s, background-color .12s;
  white-space: nowrap; text-decoration: none;
}
.nav-link:hover { background-color: #f7f7f7; color: #f56932; }
.nav-link.active { color: #f56932; font-weight: 500; }
.btn-nav {
  background: none; border: none;
  font-weight: 400; color: #595959; padding: 0;
  min-width: 72px; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.btn-nav:hover { color: #f56932; background: #f7f7f7; }
.person-count { font-size: 12px; color: #aaa; white-space: nowrap; }
.header-people-count { font-size: 12px; color: #aaa; white-space: nowrap; padding: 0 0 0 12px; margin-left: auto; flex-shrink: 0; }

/* Dark header variant (AI Research page only) */
.site-header.dark {
  background: #111; color: #fff;
  border-bottom: 2px solid #000;
}
.site-header.dark .logo { color: #fff; }
.site-header.dark .logo-text { color: #fff; }
.site-header.dark .nav-link { color: rgba(255,255,255,.7); }
.site-header.dark .nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.site-header.dark .nav-link.active { color: #f56932; font-weight: 500; }
.site-header.dark .btn-nav { color: rgba(255,255,255,.7); }
.site-header.dark .btn-nav:hover { color: #fff; background: rgba(255,255,255,.06); }
.site-header.dark .header-search { margin-right: 20px; }
.site-header.dark .header-search-input { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.15); color: #fff; }
.site-header.dark .header-search-input::placeholder { color: rgba(255,255,255,.35); }
.site-header.dark .header-search-icon { color: rgba(255,255,255,.3); }
.site-header.dark .header-people-count { color: rgba(255,255,255,.4); }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main-content { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 0 24px 48px; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer { background: var(--bg); border-top: 1px solid var(--border); color: var(--text-faint); font-size: 12px; padding: 16px 24px; text-align: center; margin-top: auto; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px; border-radius: 8px; font-size: 14px;
  font-weight: 600; border: none; transition: all .15s; cursor: pointer;
}
.btn-primary { background: #555; color: #fff; }
.btn-primary:hover { background: #3a3a3a; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid #ddd; }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-ghost); }
.btn-danger { background: #d63031; color: #fff; }
.btn-danger:hover { background: #b52020; }
.btn-large { padding: 11px 28px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { background: none; border: none; color: var(--text-ghost); font-size: 14px; padding: 2px 6px; border-radius: 4px; }
.btn-icon:hover { color: #d63031; background: #fef2f2; }
.btn-sm { font-size: 12px; padding: 4px 10px; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 6px; color: var(--text-2); }
.btn-sm:hover { background: #ece9e4; }
.btn-danger-sm { background: #fef2f2; color: #d63031; border-color: #fcc; }
.btn-danger-sm:hover { background: #fde8e8; }
.btn-sm-header { padding: 4px 12px; font-size: 13px; }
.btn-remove { background: none; border: none; color: #d63031; font-size: 11px; padding: 2px 6px; width: 100%; text-align: center; }
.btn-remove:hover { text-decoration: underline; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: 10px;
  border: 1px solid var(--border); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 14px; font-weight: 600; color: var(--text); }

/* ── Welcome / Home Page ──────────────────────────────────────────────────── */
.welcome-section { text-align: center; padding: 100px 20px; }
.welcome-inner { max-width: 480px; margin: 0 auto; }
.welcome-icon { font-size: 56px; margin-bottom: 24px; }
.welcome-section h1 { font-size: 34px; font-weight: 400; color: var(--text); margin-bottom: 12px; }
.welcome-section p { color: var(--text-3); margin-bottom: 28px; line-height: 1.7; font-size: 15px; }

.stats-bar { background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 10px 0; margin-bottom: 28px; }
.stat-item { display: inline-flex; align-items: center; gap: 8px; padding: 0 20px; }
.stat-num { font-size: 20px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-muted); }

.recent-section { margin-bottom: 36px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 20px; font-weight: 500; color: var(--text); }
.section-link { color: var(--text-2); font-size: 13px; font-weight: 600; }
.section-link:hover { text-decoration: underline; }

/* ── Person Grid ──────────────────────────────────────────────────────────── */
.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.person-card {
  background: var(--surface); border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border); transition: box-shadow .15s;
}
.person-card:hover { box-shadow: 0 4px 16px var(--shadow); }
.person-card-photo { height: 120px; background: var(--surface-3); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.person-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder { font-size: 48px; }
.person-card-info { padding: 10px 12px; }
.person-card-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; line-height: 1.3; }
.person-card-years { font-size: 12px; color: #999; margin-bottom: 2px; }
.person-card-place { font-size: 11px; color: var(--text-ghost); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mini-person-card { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; margin-bottom: 4px; transition: background .1s; }
.mini-person-card:hover { background: var(--surface-2); }
.mini-photo { font-size: 22px; flex-shrink: 0; }
.mini-name { font-size: 13px; font-weight: 600; }
.mini-years { font-size: 11px; color: #999; }

/* ── Profile Page ─────────────────────────────────────────────────────────── */
.profile-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.profile-header-inner {
  max-width: 1160px; margin: 0 auto; padding: 28px 24px;
  display: flex; align-items: flex-start; gap: 24px;
}
.profile-photo-wrap { flex-shrink: 0; }
.profile-photo, .profile-photo-placeholder {
  width: 90px; height: 90px; border-radius: 50%; object-fit: cover;
  border: 2px solid #ebe8e4; background: var(--surface-3);
  font-size: 46px; display: flex; align-items: center; justify-content: center;
}
.profile-header-info { flex: 1; }
.profile-breadcrumb { font-size: 12px; color: var(--text-faint); margin-bottom: 8px; }
.profile-breadcrumb a { color: var(--text-2); }
.profile-breadcrumb a:hover { text-decoration: underline; }
.profile-breadcrumb span { margin: 0 4px; }
.profile-name { font-size: 26px; font-weight: 700; color: var(--text); margin-bottom: 8px; line-height: 1.2; }
.profile-maiden { font-size: 17px; font-weight: 400; color: var(--text-faint); }
.profile-gender-icon { font-size: 16px; margin-left: 6px; }
.profile-vitals { display: flex; flex-wrap: wrap; gap: 16px; }
.vital { font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.vital-icon { font-size: 14px; }
.living-badge { background: #f5f5f5; color: var(--text-2); padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; border: 1px solid #d0d0d0; }
.profile-actions { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.profile-tabs {
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; gap: 0; max-width: 100%;
}
.tab {
  padding: 13px 20px; font-size: 13px; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .12s;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text-2); border-bottom-color: var(--text-2); font-weight: 600; }
.profile-body { padding: 28px 0; }
.tab-content { max-width: 1160px; margin: 0 auto; padding: 0 24px; }

/* ── Facts / Timeline ─────────────────────────────────────────────────────── */
.facts-layout { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }
.timeline { padding: 4px 0; }
.timeline-item {
  display: flex; align-items: flex-start; gap: 14px; padding: 14px 18px;
  border-bottom: 1px solid var(--border); position: relative;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-icon { font-size: 18px; flex-shrink: 0; width: 26px; text-align: center; }
.timeline-body { flex: 1; }
.timeline-type { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin-bottom: 2px; }
.timeline-date { font-size: 14px; color: var(--text); font-weight: 600; }
.timeline-place { font-size: 13px; color: var(--text-muted); }
.timeline-desc { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.timeline-del { flex-shrink: 0; }
.empty-state { padding: 28px 18px; color: var(--text-ghost); font-size: 14px; }

/* ── Family Tab ───────────────────────────────────────────────────────────── */
.family-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.family-section { background: var(--surface); border-radius: 10px; border: 1px solid var(--border); padding: 18px; }
.family-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.family-cards { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.family-member-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; min-width: 130px; text-align: center;
  transition: border-color .15s, box-shadow .15s;
}
.family-member-card:hover { border-color: var(--text-2); box-shadow: 0 2px 8px var(--shadow); }
.family-member-link { display: block; }
.family-member-link-only { display: block; text-align: center; }
.family-member-photo { font-size: 28px; margin-bottom: 6px; }
.family-member-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.family-member-years { font-size: 11px; color: var(--text-faint); margin-bottom: 6px; }
.add-rel-form { display: flex; gap: 8px; align-items: center; }
.form-input-inline { flex: 1; }

/* ── Gallery ──────────────────────────────────────────────────────────────── */
.gallery-layout { display: grid; grid-template-columns: 1fr 260px; gap: 20px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; padding: 4px; }
.gallery-item { background: var(--surface); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.gallery-thumb img { width: 100%; height: 160px; object-fit: cover; }
.gallery-doc-thumb { height: 160px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); }
.doc-icon { font-size: 48px; }
.gallery-info { padding: 10px; }
.gallery-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.gallery-date { font-size: 11px; color: var(--text-faint); margin-bottom: 8px; }
.gallery-actions { display: flex; gap: 6px; }

/* ── Notes ────────────────────────────────────────────────────────────────── */
.notes-body { padding: 18px; font-size: 14px; line-height: 1.8; color: var(--text-2); white-space: pre-wrap; }

/* ── Search Page ──────────────────────────────────────────────────────────── */
.search-page { padding-top: 32px; }
.search-header { display: flex; align-items: baseline; gap: 16px; margin-bottom: 20px; }
.search-header h1 { font-size: 26px; font-weight: 400; }
.search-count { color: var(--text-faint); font-size: 13px; }
.search-bar-full { display: flex; gap: 10px; margin-bottom: 24px; }
.search-input-full {
  flex: 1; padding: 10px 16px; border: 1px solid var(--border-2); border-radius: 8px;
  font-size: 14px; outline: none; background: var(--surface); transition: border-color .15s;
}
.search-input-full:focus { border-color: var(--text-2); box-shadow: 0 0 0 3px rgba(80,80,80,.08); }
.search-results { background: var(--surface); border-radius: 10px; border: 1px solid var(--border); overflow: hidden; }
.search-result-row {
  display: flex; align-items: center; gap: 16px; padding: 13px 18px;
  border-bottom: 1px solid var(--border); transition: background .1s; color: var(--text);
}
.search-result-row:last-child { border-bottom: none; }
.search-result-row:hover { background: var(--surface-2); }
.search-result-photo { flex-shrink: 0; }
.search-result-photo img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
.photo-placeholder-sm { width: 44px; height: 44px; border-radius: 6px; background: var(--surface-3); font-size: 22px; display: flex; align-items: center; justify-content: center; }
.search-result-info { flex: 1; }
.search-result-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.search-result-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-muted); }
.maiden-tag { color: var(--text-ghost); font-weight: 400; font-size: 12px; }
.search-result-arrow { color: #ddd; font-size: 18px; }
.empty-search { text-align: center; padding: 70px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }

/* ── Edit Page ────────────────────────────────────────────────────────────── */
.edit-page { max-width: 800px; margin: 0 auto; padding-top: 32px; }
.edit-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.edit-header h1 { font-size: 26px; font-weight: 400; }
.form-sections { display: flex; flex-direction: column; gap: 0; }
.form-section {
  background: var(--surface); border-radius: 10px; border: 1px solid var(--border);
  padding: 20px; margin-bottom: 14px;
}
.form-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 120px; }
.form-group-sm { max-width: 110px; }
.form-group-lg { flex: 2; }
.form-group-xl { flex: 3; }
.form-group-check { justify-content: flex-end; padding-bottom: 2px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-3); letter-spacing: .02em; }
.required { color: #d63031; }
.form-input {
  padding: 8px 12px; border: 1px solid var(--border-2); border-radius: 7px;
  font-size: 14px; font-family: inherit; outline: none; background: var(--surface);
  transition: border-color .15s;
}
.form-input:focus { border-color: var(--text-2); box-shadow: 0 0 0 3px rgba(80,80,80,.08); }
select.form-input { 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='M6 8L0 0h12z' fill='%23aaa'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-hint { font-size: 11px; color: var(--text-ghost); margin-top: 3px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.form-actions { display: flex; gap: 12px; padding: 20px 0; }
.form-compact { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; }

.current-photo { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.photo-preview { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid #ebe8e4; }
.photo-label { font-size: 13px; color: var(--text-faint); }

/* ── Confirm Delete ───────────────────────────────────────────────────────── */
.confirm-page { max-width: 460px; margin: 80px auto; padding: 0 20px; }
.confirm-card { background: var(--surface); border-radius: 12px; border: 1px solid var(--border); padding: 36px; text-align: center; }
.confirm-card h1 { font-size: 26px; font-weight: 400; margin-bottom: 16px; }
.confirm-card p { color: var(--text-3); line-height: 1.6; margin-bottom: 8px; font-size: 14px; }
.confirm-warning { color: #d63031; font-size: 13px; }
.confirm-actions { display: flex; gap: 12px; justify-content: center; margin-top: 28px; }


/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .facts-layout, .gallery-layout { grid-template-columns: 1fr; }
  .family-sections { grid-template-columns: 1fr; }
  .profile-header-inner { flex-wrap: wrap; padding: 16px 14px; }
  .profile-actions { flex-direction: row; flex-wrap: wrap; }
  .header-search { display: none; }
  .main-content { padding: 0 14px 32px; }
  .welcome-section { padding: 48px 14px; }
  .welcome-section h1 { font-size: 26px; }
  .person-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .section-title { font-size: 17px; }
  .stats-bar { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .profile-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .profile-tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 11px 14px; font-size: 12px; }
  .profile-name { font-size: 21px; }
  .profile-vitals { gap: 10px; }
  .tab-content { padding: 0 14px; }
}

/* Hamburger + mobile dropdown nav */
.nav-hamburger {
  display: none; background: none; border: none;
  color: var(--text-2); font-size: 20px; cursor: pointer;
  padding: 4px 8px; line-height: 1;
}
.mobile-nav {
  display: none; position: fixed; top: 56px; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-left: none; border-top: none;
  box-shadow: -4px 4px 20px rgba(0,0,0,.15);
  flex-direction: column; min-width: 180px; z-index: 2000;
  overflow: hidden;
}
.mobile-nav.open { display: flex; }
.mobile-nav-link {
  padding: 12px 18px; font-size: 15px; color: var(--text);
  text-decoration: none; border-bottom: 1px solid var(--border);
}
.mobile-nav-link:last-child { border-bottom: none; }
.mobile-nav-link:hover { background: var(--surface-2); }

@media (max-width: 768px) {
  .header-inner { padding: 0 12px; position: relative; }
  .main-nav { display: none !important; }
  .nav-hamburger { display: block; margin-left: auto; order: 100; }
  .header-search { display: none !important; }
  .person-count { display: none; }
  .header-people-count { display: none; }
  .logo-text { font-size: 14px; }
}
