* {
  box-sizing: border-box;
}

:root {
  --navy: #123b68;
  --blue: #0e6be6;
  --green: #18a660;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --border: #dce3ec;
  --danger: #b42318;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

[hidden] {
  display: none !important;
}


/* LOGIN */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px;
}

.login-icon {
  font-size: 28px;
  text-align: center;
  font-weight: 800;
}

.login-card h1 {
  text-align: center;
}

.login-card label {
  display: block;
  margin: 18px 0 7px;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  padding: 13px;
  border: 1px solid #cfd9e6;
  border-radius: 8px;
}

.wide {
  width: 100%;
  margin-top: 14px;
}


/* TOP */

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 18px 26px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.brand-title {
  font-size: 28px;
  font-weight: 800;
}

.brand-tagline {
  opacity: .9;
  margin-top: 3px;
}

.top-actions,
.editor-actions,
.tree-toolbar-buttons,
.selector-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}


/* BUTTONS */

.primary,
.save,
.secondary,
.danger,
.rel-btn,
.photo-button,
.tree-top-button,
.address-add-button,
.tree-action-button {
  border-radius: 8px;
  padding: 11px 15px;
  font-weight: 700;
}

.primary {
  border: 0;
  background: var(--green);
  color: #fff;
}

.save,
.tree-action-button {
  border: 0;
  background: var(--blue);
  color: #fff;
}

.save:disabled {
  background: #c8ced6;
  color: #737b85;
}

.secondary {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #172033;
}

.danger {
  border: 1px solid #efb6b6;
  background: #fff5f5;
  color: var(--danger);
}

.tree-top-button {
  border: 0;
  background: #e9f2ff;
  color: #135fb8;
}

.tree-top-button:disabled {
  background: #68798c;
  color: #d8e0e8;
}

.rel-btn {
  border: 1px solid #377ddd;
  background: #fff;
  color: #175bb2;
}


/* MAIN */

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 22px;
  padding: 22px;
  max-width: 1500px;
  margin: auto;
}

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.sidebar {
  padding: 18px;
}

.sidebar h2 {
  margin-top: 0;
}

.search {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccd7e5;
  border-radius: 8px;
  margin-bottom: 12px;
}

.person-item {
  width: 100%;
  border: 0;
  background: #fff;
  text-align: left;
  padding: 12px;
  border-radius: 9px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.person-item.active {
  outline: 1px solid #4b8cf5;
  background: #f1f6ff;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #eaf1fb;
  color: #2364bd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  overflow: hidden;
  flex: 0 0 auto;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pname {
  display: block;
  font-weight: 700;
}

.meta {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}


/* EDITOR */

.editor {
  padding: 20px 24px;
}

.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.person-details {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 24px;
}

.person-form {
  min-width: 0;
}

.photo-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  padding: 14px;
  text-align: center;
}

.photo-preview {
  width: 150px;
  height: 150px;
  border-radius: 14px;
  margin: 0 auto 12px;
  background: #e8eef6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  font-weight: 800;
  overflow: hidden;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-upload {
  display: none;
}

.photo-button {
  display: inline-block;
  border: 1px solid #377ddd;
  background: #fff;
  color: #175bb2;
}

.photo-help {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}


/* FORM */

.name-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 22px;
  margin-bottom: 18px;
}

.span-all {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 7px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #cfd9e6;
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
}

.date-location-grid {
  display: grid;
  grid-template-columns:
    180px
    minmax(220px, 1fr)
    150px;
  gap: 16px;
  align-items: end;
  margin: 18px 0;
}

.sex-row {
  display: grid;
  grid-template-columns: 180px minmax(220px, 1fr);
  gap: 16px;
  align-items: end;
  margin: 18px 0;
}

.notes-section {
  margin-top: 18px;
}


/* ADDRESS */

.address-section {
  margin: 22px 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
}

.address-heading {
  padding: 14px 16px;
  background: #f7f9fc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.address-heading h3 {
  margin: 0;
}

.address-heading p {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.address-add-button {
  border: 1px solid #377ddd;
  background: #fff;
  color: #175bb2;
}

.address-editor {
  padding: 16px;
  background: #f9fbfe;
  border-top: 1px solid var(--border);
}

.address-editor-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.small-button {
  padding: 7px 10px;
  font-size: 13px;
}

.address-form-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 15px;
}

.current-address-box {
  display: flex;
  align-items: end;
  padding-bottom: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.checkbox-label input {
  width: auto;
}

.address-row {
  display: grid;
  grid-template-columns:
    150px
    minmax(250px, 1fr)
    150px
    auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid #e8ecf2;
}

.address-label {
  font-weight: 800;
}

.address-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.address-dates {
  color: var(--muted);
  font-size: 13px;
}

.address-actions,
.row-actions {
  display: flex;
  gap: 6px;
}

.address-edit,
.address-copy,
.address-delete,
.edit-related,
.parent-edit,
.parent-remove,
.spouse-relation-edit,
.spouse-relation-remove {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.address-edit,
.edit-related,
.parent-edit,
.spouse-relation-edit {
  border: 1px solid #8bb8f2;
  background: #f4f8ff;
  color: #175bb2;
}

.address-delete,
.parent-remove,
.spouse-relation-remove {
  border: 1px solid #efb6b6;
  background: #fff5f5;
  color: var(--danger);
}

.address-empty {
  padding: 14px;
  color: var(--muted);
}

.copy-target-panel {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid #e8ecf2;
  background: #f8fafc;
}

.copy-target-panel label {
  margin: 0;
  white-space: nowrap;
}

.copy-target-panel select {
  min-width: 0;
}


/* RELATIONSHIPS */

.relationships {
  margin-top: 24px;
  border-top: 1px solid #e1e6ee;
  padding-top: 22px;
}

.rel-note {
  color: var(--muted);
}

.relationship-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 16px 0;
  overflow: hidden;
}

.relationship-section-head {
  background: #f7f9fc;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.relationship-section-head h3 {
  margin: 0;
}

.relationship-section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.direct-list-row {
  display: grid;
  grid-template-columns:
    190px
    minmax(0, 1fr)
    minmax(180px, auto)
    auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid #e8ecf2;
}

.direct-type {
  font-weight: 700;
}

.marriage-dates {
  color: var(--muted);
  font-size: 13px;
}

.selector {
  margin-bottom: 18px;
  padding: 16px;
  background: #f8fbff;
  border: 1px solid #cfe1f7;
  border-radius: 10px;
}

.selector h3 {
  margin-top: 0;
}

.parent-selector-grid {
  display: grid;
  grid-template-columns:
    minmax(220px, 1fr)
    180px
    auto
    auto;
  gap: 10px;
  align-items: end;
}

.spouse-form-grid {
  display: grid;
  grid-template-columns:
    minmax(220px, 1fr)
    170px
    170px
    170px;
  gap: 12px;
  align-items: end;
}

.selector-button-cell {
  display: flex;
  align-items: end;
}

.selector-actions {
  margin-top: 14px;
}

.selector-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.compact-tools {
  margin: 14px 0;
}

.copy-address-grid {
  display: grid;
  grid-template-columns:
    minmax(180px, 1fr)
    minmax(180px, 1fr)
    auto
    auto;
  gap: 10px;
}

.linked {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.linked-title {
  background: #f7f9fc;
  padding: 12px 14px;
  font-weight: 800;
}

.calculated-note {
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid #e8ecf2;
}

.linked-row {
  display: grid;
  grid-template-columns:
    190px
    minmax(0, 1fr)
    auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid #e8ecf2;
}

.type {
  font-weight: 700;
}


/* STATUS */

.status {
  min-height: 22px;
  margin-top: 14px;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
  font-weight: 700;
}

.status.success {
  color: #176b42;
  font-weight: 700;
}


/* TREE */

.tree-screen {
  padding: 28px;
  max-width: 1450px;
  margin: auto;
}

.tree-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.tree-subtitle {
  color: var(--muted);
}

.tree-section-label {
  text-align: center;
  font-weight: 800;
  color: #58677a;
  margin: 25px 0 13px;
}

.tree-row,
.aunts-uncles-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.tree-couple-row {
  gap: 45px;
}

.tree-card {
  width: 205px;
  min-height: 210px;
  border: 1px solid #d3dce8;
  border-radius: 16px;
  background: #fff;
  padding: 16px;
  text-align: center;
}

.tree-card.current,
.tree-card.parent-highlight {
  border: 3px solid #276ed8;
}

.tree-card.empty {
  border-style: dashed;
}

.tree-photo {
  width: 100px;
  height: 100px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #e8eef6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 800;
  overflow: hidden;
}

.tree-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tree-name {
  font-weight: 800;
}

.tree-relation {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.tree-vertical-line {
  width: 2px;
  height: 35px;
  background: #aeb9c8;
  margin: 0 auto;
}

.tree-children {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(185px, 205px));
  gap: 20px;
  justify-content: center;
}


/* GRANDKIDS */

.grandkids-families {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(420px, 1fr));
  gap: 24px;
}

.grandkids-family-group {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.grandkids-parent-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
}

.grandkids-spouse-line {
  width: 35px;
  height: 2px;
  background: #aeb9c8;
}

.grandkids-connector,
.cousin-connector {
  width: 2px;
  height: 28px;
  background: #aeb9c8;
  margin: 12px auto;
}

.grandkids-label,
.cousin-label {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 12px;
}

.grandkids-list,
.cousin-list {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.grandchild-card,
.cousin-card {
  width: 165px;
  min-height: 185px;
}

.grandchild-card .tree-photo,
.cousin-card .tree-photo {
  width: 80px;
  height: 80px;
}


/* AUNTS / UNCLES */

.family-side-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 24px;
}

.aunts-uncles-row .tree-card {
  width: 180px;
  min-height: 195px;
}


/* COUSINS */

.cousin-side-section {
  margin-bottom: 30px;
}

.cousin-families {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}

.cousin-family-group {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}

.cousin-parent-title {
  text-align: center;
  font-weight: 800;
  margin-bottom: 5px;
}

.cousin-parent-relation {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.cousin-parent-card {
  display: flex;
  justify-content: center;
}

.no-grandkids,
.no-family-members,
.no-cousins {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
}


/* TABLET */

@media (max-width: 1000px) {

  .layout {
    grid-template-columns: 1fr;
  }

  .person-details {
    grid-template-columns: 1fr;
  }

  .spouse-form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .direct-list-row {
    grid-template-columns:
      170px
      minmax(0, 1fr)
      auto;
  }

  .marriage-dates {
    grid-column: 2;
  }

}


/* PHONE */

@media (max-width: 700px) {

  .name-grid,
  .form-grid,
  .date-location-grid,
  .address-form-grid,
  .parent-selector-grid,
  .spouse-form-grid,
  .copy-address-grid {
    grid-template-columns: 1fr;
  }

  .span-all {
    grid-column: auto;
  }

  .sex-row,
  .copy-target-panel {
    grid-template-columns: 1fr;
  }

  .address-row,
  .direct-list-row,
  .linked-row {
    grid-template-columns: 1fr;
  }

  .marriage-dates {
    grid-column: auto;
  }

  .address-text {
    white-space: normal;
  }

  .tree-card {
    width: 150px;
    min-height: 180px;
    padding: 10px;
  }

  .tree-photo {
    width: 78px;
    height: 78px;
  }

  .grandkids-family-group,
  .cousin-family-group {
    padding: 12px;
  }

  .grandkids-spouse-line {
    display: none;
  }

}
/* DOCUMENTS */

.documents-section {
  margin: 24px 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
  background: #fff;
}

.documents-heading {
  padding: 14px 16px;
  background: #f7f9fc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.documents-heading h2 {
  margin: 0;
  font-size: 20px;
}

.documents-heading p {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.document-editor {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: #f9fbfe;
}

.document-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.document-picture-box {
  margin-bottom: 16px;
}

.document-preview {
  width: min(520px, 100%);
  min-height: 180px;
  max-height: 360px;
  border: 1px dashed #b9c6d8;
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 12px;
  padding: 12px;
  text-align: center;
}

.document-preview img {
  display: block;
  max-width: 100%;
  max-height: 330px;
  object-fit: contain;
}

.document-list {
  border-top: 1px solid var(--border);
}

.document-empty {
  padding: 16px;
  color: var(--muted);
}

.document-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.document-row:last-child {
  border-bottom: 0;
}

.document-info {
  min-width: 0;
  flex: 1 1 auto;
}

.document-name {
  font-weight: 800;
}

.document-dates,
.document-notes {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.document-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.document-actions button {
  border: 1px solid #bfd0e5;
  background: #fff;
  border-radius: 7px;
  padding: 7px 10px;
  font-weight: 700;
}

.document-actions .document-display {
  color: #175bb2;
}

.document-actions .document-delete {
  color: var(--danger);
  border-color: #efb6b6;
}

.document-actions button:disabled {
  opacity: .45;
}

.document-viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #10151d;
  display: flex;
  flex-direction: column;
}

.document-viewer-bar {
  background: #fff;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.document-viewer-title {
  font-weight: 800;
}

.document-viewer-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: auto;
}

.document-viewer-body img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

body.document-viewer-open {
  overflow: hidden;
}

@media (max-width: 700px) {
  .document-form-grid {
    grid-template-columns: 1fr;
  }

  .document-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .document-actions {
    width: 100%;
    justify-content: flex-start;
  }
}


/* MEMBER SORT */
.member-sort-row {
  margin: 0 0 12px;
}
.member-sort-row label {
  margin-bottom: 5px;
}
.member-sort-row select {
  width: 100%;
}

/* FAMILY GROUP DROPDOWN */
.family-group-picker {
  min-width: 220px;
}
.family-group-picker label {
  color: inherit;
  margin-bottom: 5px;
}
.family-group-picker select {
  min-width: 220px;
  background: #fff;
}

.family-group-results {
  padding: 24px;
}
.family-group-card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
}

@media (max-width: 700px) {
  .family-group-picker,
  .family-group-picker select {
    width: 100%;
    min-width: 0;
  }
}


/* =========================================================
   READ ONLY FAMILY ACCOUNT
   ========================================================= */

.family-access-badge {
  background: #fff4d6;
  color: #7a4b00;
  border: 1px solid #e5bd64;
  border-radius: 9px;
  padding: 10px 14px;
  font-weight: 800;
  white-space: nowrap;
}

body.read-only-mode input:disabled,
body.read-only-mode select:disabled,
body.read-only-mode textarea:disabled {
  background: #f7f8fa;
  color: #374151;
  opacity: 1;
  cursor: default;
}

/* Controls that change data disappear for Read Only users. */
body.read-only-mode #addPersonButton,
body.read-only-mode #saveButton,
body.read-only-mode #deleteButton,
body.read-only-mode #photoUpload,
body.read-only-mode label[for="photoUpload"],
body.read-only-mode #addAddressButton,
body.read-only-mode #saveAddressButton,
body.read-only-mode #addDocumentButton,
body.read-only-mode #saveDocumentButton,
body.read-only-mode #addParentButton,
body.read-only-mode #saveParentButton,
body.read-only-mode #addSpouseButton,
body.read-only-mode #saveSpouseButton,
body.read-only-mode .address-edit,
body.read-only-mode .address-copy,
body.read-only-mode .address-delete,
body.read-only-mode .document-edit,
body.read-only-mode .document-delete,
body.read-only-mode .parent-edit,
body.read-only-mode .parent-remove,
body.read-only-mode .spouse-relation-edit,
body.read-only-mode .spouse-relation-remove,
body.read-only-mode .edit-related,
body.read-only-mode .confirm-copy-address,
body.read-only-mode .cancel-copy-address {
  display: none !important;
}

@media (max-width: 700px) {
  .family-access-badge {
    width: 100%;
    text-align: center;
  }
}


/* DATE LIST - description, date and location on one line */
.date-list-row {
  align-items: center;
}

.date-entry-content {
  min-width: 0;
  flex: 1 1 auto;
}

.date-summary-line {
  display: flex;
  align-items: baseline;
  gap: 7px;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.date-separator {
  color: var(--muted);
  flex: 0 0 auto;
}

.date-notes {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

/* Current Relationships no longer has an Edit-button column */
.linked-row {
  grid-template-columns: 190px minmax(0, 1fr);
}


/* SIBLINGS FAMILY GROUP */
.siblings-connection-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.siblings-selected-row,
.siblings-card-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  width: 100%;
}

.siblings-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.siblings-connector-line {
  width: 2px;
  height: 24px;
  background: #9aa8b7;
}

.siblings-connector-label {
  font-size: 13px;
  font-weight: 700;
  color: #667788;
  padding: 4px 10px;
  border: 1px solid #cbd4de;
  border-radius: 999px;
  background: #f7f9fc;
}


/* SPOUSES FAMILY GROUP */
.spouses-connection-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.spouses-selected-row,
.spouses-card-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  width: 100%;
}

.spouse-history-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.spouse-history-detail {
  max-width: 220px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #667788;
}

.spouses-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.spouses-connector-line {
  width: 2px;
  height: 24px;
  background: #9aa8b7;
}

.spouses-connector-label {
  font-size: 13px;
  font-weight: 700;
  color: #667788;
  padding: 4px 10px;
  border: 1px solid #cbd4de;
  border-radius: 999px;
  background: #f7f9fc;
}


/* GREAT-GRANDCHILDREN FAMILY CONNECTION */
.great-grandchildren-family-view {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.great-grandchildren-selected {
  display: flex;
  justify-content: center;
  width: 100%;
}

.great-grandchildren-down-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin: 8px 0;
}

.generation-vertical-line {
  width: 2px;
  height: 22px;
  background: #9aa8b7;
}

.generation-line-label {
  font-size: 13px;
  font-weight: 700;
  color: #667788;
  padding: 4px 10px;
  border: 1px solid #cbd4de;
  border-radius: 999px;
  background: #f7f9fc;
}

.great-grandchildren-paths {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
}

.great-grandchild-path {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px;
  border: 1px solid #dbe2eb;
  border-radius: 16px;
  background: #f8fafc;
}

.generation-connector {
  font-size: 30px;
  font-weight: 800;
  color: #7b8999;
  flex: 0 0 auto;
}

@media (max-width: 800px) {
  .great-grandchild-path {
    flex-direction: column;
  }

  .generation-connector {
    transform: rotate(90deg);
  }
}


/* RELATIONSHIP PATH FAMILY GROUPS */
.relationship-family-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.relationship-paths {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}

.relationship-path-block {
  width: 100%;
  padding: 16px;
  border: 1px solid #dbe2eb;
  border-radius: 16px;
  background: #f8fafc;
}

.relationship-path-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.relationship-path-card-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.relationship-down-connector {
  display: flex;
  justify-content: center;
  margin: 4px 0;
}

.siblings-pair-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.sibling-horizontal-connector {
  font-size: 13px;
  font-weight: 700;
  color: #667788;
  padding: 5px 12px;
  border: 1px solid #cbd4de;
  border-radius: 999px;
  background: #ffffff;
}

.compact-family-message {
  padding: 12px;
}

@media (max-width: 900px) {
  .relationship-path-row,
  .four-generation-path,
  .siblings-pair-row {
    flex-direction: column;
  }

  .relationship-path-row .generation-connector {
    transform: rotate(90deg);
  }
}


/* MAIN FM CENTRAL HELP */
.help-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow-y: auto;
  padding: 28px;
  background: rgba(20, 31, 45, 0.58);
}

.help-screen[hidden] {
  display: none !important;
}

.help-panel {
  width: min(980px, 100%);
  margin: 0 auto;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.help-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  border-bottom: 1px solid #dbe2eb;
  background: #ffffff;
}

.help-header h1 {
  margin: 0 0 5px;
}

.help-header p {
  margin: 0;
  color: #667788;
}

.help-content {
  padding: 8px 28px 30px;
}

.help-section {
  padding: 20px 0;
  border-bottom: 1px solid #e2e7ed;
}

.help-section h2 {
  margin: 0 0 12px;
  color: #425f80;
}

.help-section h3 {
  margin: 16px 0 5px;
  font-size: 17px;
}

.help-section p {
  margin: 7px 0;
  line-height: 1.6;
}

.help-footer {
  display: flex;
  justify-content: center;
  padding: 28px 0 4px;
}

.help-footer button {
  min-width: 180px;
}

body.help-open {
  overflow: hidden;
}

@media (max-width: 650px) {
  .help-screen {
    padding: 10px;
  }

  .help-header {
    padding: 18px;
    flex-direction: column;
  }

  .help-content {
    padding: 5px 18px 24px;
  }
}


/* Progressive Web App install helper */
.install-app-screen {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: rgba(0, 0, 0, .52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.install-app-screen[hidden] {
  display: none;
}

.install-app-panel {
  width: min(620px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, .28);
}

.install-app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.install-app-header h2 {
  margin: 0 0 6px;
}

.install-app-header p {
  margin: 0;
}

.install-app-instructions h3 {
  margin-top: 0;
}

.install-app-instructions ol {
  padding-left: 24px;
  line-height: 1.7;
}

.install-app-instructions p {
  line-height: 1.55;
}

body.install-app-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .install-app-panel {
    padding: 18px;
  }

  .install-app-header {
    flex-direction: column;
  }

  .install-app-header > button {
    width: 100%;
  }
}


/* Change Password */
.change-password-screen {
  position: fixed;
  inset: 0;
  z-index: 13000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 31, 45, 0.58);
}

.change-password-screen[hidden] {
  display: none !important;
}

.change-password-panel {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
}

.change-password-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.change-password-header h2 {
  margin: 0 0 6px;
}

.change-password-header p {
  margin: 0;
  color: #667788;
  line-height: 1.45;
}

.change-password-form {
  display: grid;
  gap: 8px;
}

.change-password-form label {
  margin-top: 8px;
  font-weight: 700;
}

.change-password-form input {
  width: 100%;
  box-sizing: border-box;
}

.change-password-note {
  margin: 4px 0 0;
  color: #667788;
  font-size: 0.92rem;
}

.change-password-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

body.change-password-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .change-password-panel {
    padding: 18px;
  }

  .change-password-header {
    flex-direction: column;
  }

  .change-password-header > button {
    width: 100%;
  }

  .change-password-actions {
    flex-direction: column;
  }

  .change-password-actions button {
    width: 100%;
  }
}

/* Logged-in user name beside FM Central */
.logged-in-user-name {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.72em;
  font-weight: 600;
  opacity: 0.9;
  vertical-align: middle;
}
