:root {
  --color-primary: #1f6b5c;
  --color-primary-dark: #174f44;
  --color-accent: #c9a227;
  --color-accent-dark: #a8861a;
  --color-danger: #c0392b;
  --color-surface: #ffffff;
  --color-bg: #f4f7f6;
  --color-text: #1f2933;
  --color-muted: #6b7c86;
  --page-max-width: 1140px;
  --spacing-page-top: 72px;
  --radius-card: 12px;
  --shadow-card: 0 8px 24px rgba(31, 41, 51, 0.08);
  --bottom-nav-height: 64px;
}

body.app-body {
  font-family: 'Source Sans 3', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: var(--color-text);
  background-color: var(--color-bg);
}

body.has-bottom-nav {
  padding-bottom: calc(var(--bottom-nav-height) + 1rem);
}

.nav-spacer {
  height: var(--spacing-page-top);
}

.page-container {
  max-width: var(--page-max-width);
}

.page-title,
h1.page-title,
h2.page-title {
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 700;
  font-size: clamp(1.625rem, 3.5vw, 2.125rem);
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--color-text);
  margin-bottom: 0;
}

.page-title::after {
  content: '';
  display: block;
  width: 2.75rem;
  height: 3px;
  margin-top: 0.625rem;
  background: linear-gradient(90deg, var(--color-primary) 0%, rgba(31, 107, 92, 0.25) 100%);
  border-radius: 999px;
}

.page-title.text-center::after {
  margin-left: auto;
  margin-right: auto;
}

.page-subtitle {
  color: var(--color-muted);
  font-size: 1rem;
  line-height: 1.5;
  margin: 0.5rem 0 0;
  max-width: 40rem;
}

.page-header,
.container.page-container > .page-header-text,
.container.page-container > .d-flex:has(.page-title) {
  padding-bottom: 1.25rem;
  margin-bottom: 1.75rem !important;
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
}

.container.page-container > .d-flex:has(.page-title) {
  margin-bottom: 1.75rem !important;
}

.container.page-container > h1.page-title,
.container.page-container > h2.page-title {
  padding-bottom: 1rem;
  margin-bottom: 1.75rem !important;
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
}

.page-breadcrumb .breadcrumb-item {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.page-breadcrumb .breadcrumb-item a {
  color: var(--color-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.page-breadcrumb .breadcrumb-item a:hover {
  color: var(--color-primary);
}

.page-breadcrumb .breadcrumb-item.active {
  color: var(--color-primary-dark);
}

.page-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
  color: rgba(31, 41, 51, 0.25);
}

h2, h3.card-title {
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.login-box .page-title {
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.app-navbar {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(31, 107, 92, 0.12);
  box-shadow: 0 2px 12px rgba(31, 41, 51, 0.06);
}

.navbar-brand {
  font-family: 'Courgette', cursive;
  color: var(--color-primary-dark) !important;
}

.btn-primary {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

.btn-outline-primary {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-outline-primary:hover {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-warning {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
  color: #1f2933;
  font-weight: 700;
}

.btn-warning:hover,
.btn-warning:focus {
  background-color: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
  color: #1f2933;
}

.app-card,
.card.app-card {
  border: none;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  background: var(--color-surface);
}

.app-card .card-header {
  background: transparent;
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
  font-weight: 600;
}

.person-profile-photo {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.person-sidebar-links {
  border-top: 1px solid rgba(31, 41, 51, 0.08);
  padding-top: 1rem;
}

.person-sidebar-link {
  margin-bottom: 0.55rem;
  line-height: 1.3;
  word-break: break-word;
}

.person-sidebar-link:last-child {
  margin-bottom: 0;
}

.person-sidebar-link-type {
  display: block;
  font-size: 0.75rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.person-sidebar-link a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-primary);
  text-decoration: none;
}

.person-sidebar-link a:hover {
  text-decoration: underline;
  color: var(--color-primary-dark);
}

.person-sidebar-map {
  border-top: 1px solid rgba(31, 41, 51, 0.08);
  padding-top: 1rem;
}

.person-birth-map {
  width: 100%;
  max-width: 220px;
  margin-left: auto;
  margin-right: auto;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(31, 41, 51, 0.1);
  background: #e8eef3;
}

.person-birth-map--wide {
  max-width: none;
  aspect-ratio: 21 / 9;
  min-height: 280px;
}

.person-birth-map iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.person-birth-map-caption {
  text-align: center;
  max-width: 220px;
  margin-left: auto;
  margin-right: auto;
}

.person-birth-map--wide + .person-birth-map-caption {
  max-width: none;
}

.table-scroll.story-stat-table {
  /* Header + ~10 compact body rows, then scroll */
  max-height: 24rem;
}

.person-typeahead-search-wrap {
  position: relative;
}

.person-typeahead-results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 0.25rem);
  max-height: 280px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid rgba(31, 107, 92, 0.18);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.person-typeahead-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid rgba(31, 41, 51, 0.06);
}

.person-typeahead-item:last-child {
  border-bottom: 0;
}

.person-typeahead-item:hover,
.person-typeahead-item.active {
  background: rgba(31, 107, 92, 0.08);
}

.person-typeahead-item-label {
  display: block;
  font-weight: 600;
  color: var(--color-text);
}

.person-typeahead-item-meta {
  display: block;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-top: 0.1rem;
}

.person-typeahead-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(31, 107, 92, 0.18);
  border-radius: var(--radius-card);
  background: rgba(31, 107, 92, 0.05);
  margin-bottom: 0.5rem;
}

.person-typeahead-selected-label {
  font-weight: 600;
}

.action-toolbar {
  gap: 0.5rem;
}

.action-toolbar .btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.action-toolbar .btn i {
  line-height: 1;
}

.tree-page-toolbar {
  flex-wrap: nowrap;
  overflow-x: auto;
  min-width: 0;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 0.15rem;
}

.tree-page-toolbar .btn {
  flex-shrink: 0;
}

.tree-modal-toolbar {
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.tree-modal-toolbar .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.visibility-active { color: var(--color-primary); }
.visibility-inactive { color: #adb5bd; }

.table-scroll {
  display: block;
  max-height: 620px;
  width: 100%;
  overflow: auto;
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.table-scroll th {
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

.person-card {
  border: none;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  margin-bottom: 1rem;
  background: var(--color-surface);
}

.person-card .card-body {
  padding: 1rem 1.1rem;
}

.person-card-meta {
  color: var(--color-muted);
  font-size: 0.95rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.empty-state i {
  font-size: 2.5rem;
  color: var(--color-primary);
  margin-bottom: 1rem;
}

.search-panel {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1rem;
}

.tree-viewport {
  width: 100%;
  height: 70vh;
  min-height: 400px;
  border: 1px solid rgba(31, 107, 92, 0.16);
  border-radius: var(--radius-card);
  background:
    radial-gradient(circle at 12% 18%, rgba(219, 39, 119, 0.08), transparent 34%),
    radial-gradient(circle at 88% 12%, rgba(15, 118, 110, 0.1), transparent 32%),
    radial-gradient(circle at 50% 100%, rgba(201, 162, 39, 0.1), transparent 40%),
    linear-gradient(165deg, #f7fcfa 0%, #faf7ef 48%, #f9f4fb 100%);
  box-shadow: var(--shadow-card);
}

.tree-viewport-fullscreen {
  position: fixed;
  inset: var(--spacing-page-top) 0 var(--bottom-nav-height) 0;
  z-index: 1040;
  height: auto;
  border-radius: 0;
}

.tree-help {
  color: var(--color-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-top: 0.5rem;
}

.tree-legend {
  padding: 0.85rem 1rem;
  border: 1px solid rgba(31, 107, 92, 0.14);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.72);
}

.tree-legend-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.tree-legend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--color-text);
}

.tree-legend-swatch {
  display: inline-block;
  width: 1.35rem;
  height: 0.95rem;
  border-radius: 4px;
  border-style: solid;
  border-width: 3px;
  background: #f8fafc;
  flex-shrink: 0;
}

.tree-legend-swatch--male {
  border-color: #6b9fd4;
  background: #f6f9fc;
}

.tree-legend-swatch--female {
  border-color: #d4829a;
  background: #fdf7f9;
}

.tree-legend-swatch--unknown {
  border-color: #94a3b8;
  background: #f8fafc;
}

.tree-legend-swatch--end-of-line {
  border-color: #64748b;
  border-style: dashed;
  background: #f8fafc;
}

.tree-legend-swatch--linchpin {
  border-color: #c9a227;
  background: #fffdf5;
}

.tree-legend-swatch--questionable {
  border-color: #c0392b;
  background: #fdf6f5;
}

.tree-legend-note {
  margin-top: 0.65rem;
  font-size: 0.8rem;
  color: var(--color-muted);
  line-height: 1.4;
}

.stats-map {
  width: 100%;
  height: 480px;
  min-height: 320px;
}

.login-box {
  width: 100%;
  max-width: 420px;
  padding: 2rem;
  border: none;
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

body.app-body.login-page {
  background-color: transparent;
  background-image: linear-gradient(rgba(31, 107, 92, 0.45), rgba(31, 41, 51, 0.55)), url(https://ourfamily-nameplates.s3-ap-southeast-2.amazonaws.com/public/images/familytree.jpg);
  background-size: cover;
  background-position: center;
}

.auth-home-link {
  display: block;
  text-align: center;
  margin-bottom: 1rem;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--bottom-nav-height);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(31, 107, 92, 0.12);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1030;
  padding: 0 0.25rem;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  text-decoration: none;
  font-size: 0.72rem;
  min-width: 56px;
  min-height: 44px;
}

.bottom-nav-item i {
  font-size: 1.2rem;
  margin-bottom: 0.15rem;
}

.bottom-nav-item.active,
.bottom-nav-item:hover {
  color: var(--color-primary);
}

.bottom-nav-icon-wrap {
  position: relative;
  display: inline-flex;
  line-height: 1;
}

.news-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-left: 0.35rem;
  vertical-align: middle;
  border-radius: 50%;
  background: #dc3545;
  box-shadow: 0 0 0 2px #fff;
}

.news-dot-nav {
  position: absolute;
  top: -0.15rem;
  right: -0.35rem;
  margin-left: 0;
}

.news-feed-item {
  padding: 1rem 1.15rem;
}

.news-feed-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(31, 107, 92, 0.1);
  color: var(--color-primary);
}

.news-feed-icon-relationship {
  background: rgba(107, 159, 212, 0.14);
  color: #4a667d;
}

.news-feed-title {
  font-weight: 600;
  color: var(--color-text, #1f2937);
  text-decoration: none;
}

.news-feed-title:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.news-feed-summary {
  color: var(--color-muted);
  font-size: 0.92rem;
  margin-top: 0.2rem;
}

.news-feed-time {
  font-size: 0.82rem;
  white-space: nowrap;
}

.help-toc {
  columns: 1;
  gap: 2rem;
  padding-left: 1.15rem;
  margin-bottom: 0;
}

@media (min-width: 768px) {
  .help-toc {
    columns: 2;
  }
}

.help-toc li {
  break-inside: avoid;
  margin-bottom: 0.35rem;
}

.help-toc a {
  text-decoration: none;
}

.help-toc a:hover {
  text-decoration: underline;
}

.help-section {
  scroll-margin-top: 5.5rem;
}

.bottom-nav-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff !important;
  margin-top: -18px;
  box-shadow: 0 8px 20px rgba(31, 107, 92, 0.35);
}

.bottom-nav-fab i {
  font-size: 1.5rem;
  margin: 0;
}

.fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 10px 24px rgba(31, 107, 92, 0.35);
  z-index: 1020;
  text-decoration: none;
}

.fab:hover {
  color: #fff;
  background: var(--color-primary-dark);
}

.toast-stack {
  z-index: 1080;
}

#mynetwork {
  width: 100%;
  height: 100%;
}

.tree-viewport .vis-network:focus {
  outline: none;
}

.landing-hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.landing-brand {
  font-family: 'Courgette', cursive;
  font-size: 2.5rem;
}

.dropzone {
  border: 2px dashed var(--color-primary);
  border-radius: var(--radius-card);
  background-color: white;
  min-height: 150px;
  padding: 2rem;
}

.dropzone.dz-clickable { cursor: pointer; }

.dz-button {
  background: none;
  color: inherit;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background-color: #e8ecef; border-radius: 100px; }
::-webkit-scrollbar-thumb { background-color: var(--color-primary); border-radius: 100px; }

@media (max-width: 991.98px) {
  .desktop-toolbar { display: none !important; }
}

@media (min-width: 992px) {
  body.has-bottom-nav { padding-bottom: 0; }
}

@media (max-width: 767.98px) {
  .login-box { margin: 1rem; }
}

.person-identity-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
  padding: 0.85rem 1rem;
  border: 2px solid rgba(31, 41, 51, 0.12);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  text-align: left;
}

.person-identity-card--male {
  border-color: #6b9fd4;
  background: #f6f9fc;
}

.person-identity-card--female {
  border-color: #d4829a;
  background: #fdf7f9;
}

.person-identity-card--unknown {
  border-color: #94a3b8;
  background: #f8fafc;
}

.person-identity-card__media {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.person-identity-card__flag {
  width: 48px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(31, 41, 51, 0.15);
}

.person-identity-card__gender {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--color-muted);
  font-size: 1rem;
}

.person-identity-card__familysearch {
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  color: #c9a227;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 2px rgba(31, 41, 51, 0.12);
  font-size: 0.85rem;
  line-height: 1;
  text-decoration: none;
}

.person-identity-card__familysearch:hover,
.person-identity-card__familysearch:focus {
  color: #a8861a;
  text-decoration: none;
}

.person-identity-card--male .person-identity-card__gender {
  color: #4a667d;
}

.person-identity-card--female .person-identity-card__gender {
  color: #8b5a68;
}

.person-identity-card__text {
  min-width: 0;
  flex: 1;
}

.person-identity-card__name {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.25;
  color: var(--color-text);
  word-break: break-word;
}

.person-identity-card__meta {
  margin-top: 0.2rem;
  color: var(--color-muted);
  font-size: 0.95rem;
}

.person-identity-card--compact {
  max-width: none;
}
