/* =========================================================
   1. Local fonts + theme tokens
   ========================================================= */

@font-face {
  font-family: "PistonBlack";
  src: url("fonts/PistonBlack-Regular.ttf") format("truetype");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --jungle-green: #00A86B;
  --brown-red: #9C2E35;
  --eggshell: #F5EFD9;
  --camel: #B89F71;
  --smoky-rose: #8B5A4E;

  --bg: #ffffff;
  --panel: #fffdf7;
  --panel-soft: #faf7ef;
  --surface: var(--eggshell);
  --surface-2: #fffdf9;

  --text: #1f1a17;
  --text-soft: #5d473f;
  --muted: rgba(31, 26, 23, 0.68);

  --border: rgba(156, 46, 53, 0.34);
  --border-soft: rgba(156, 46, 53, 0.18);
  --border-strong: rgba(156, 46, 53, 0.8);
  --green-border: rgba(0, 168, 107, 0.36);

  --shadow-sm: 0 6px 16px rgba(79, 47, 39, 0.08);
  --shadow-md: 0 16px 40px rgba(79, 47, 39, 0.12);
  --shadow-lg: 0 28px 56px rgba(79, 47, 39, 0.18);

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;

  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-15: 15px;
  --fs-16: 16px;
  --fs-18: 18px;
  --fs-20: 20px;
  --fs-24: 24px;
  --fs-32: 32px;

  --space-4: 4px;
  --space-6: 6px;
  --space-8: 8px;
  --space-10: 10px;
  --space-12: 12px;
  --space-14: 14px;
  --space-16: 16px;
  --space-18: 18px;
  --space-20: 20px;
  --space-24: 24px;
  --space-28: 28px;
  --space-32: 32px;

  --topbar-height: 92px;
}


/* =========================================================
   2. Base reset
   ========================================================= */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top left, rgba(0, 168, 107, 0.05), transparent 24%),
    radial-gradient(circle at bottom right, rgba(156, 46, 53, 0.05), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

/* =========================================================
   3. Auth lock
   ========================================================= */

.auth-locked #treeApp {
  filter: blur(12px);
  pointer-events: none;
  user-select: none;
}

/* =========================================================
   4. Main app layout
   ========================================================= */

.tree-app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    linear-gradient(to right, rgba(184, 159, 113, 0.12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(184, 159, 113, 0.1) 1px, transparent 1px),
    var(--bg);
  background-size: 160px 100%, 100% 56px, auto;
}


/* =========================================================
   5. Header / brand
   ========================================================= */

.tree-topbar {
  min-height: var(--topbar-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-20);
  padding: 14px 24px;
  border-bottom: 1px solid rgba(156, 46, 53, 0.16);
  background: var(--camel);
  backdrop-filter: blur(12px);
  z-index: 30;
}

.tree-brand {
  display: flex;
  align-items: center;
  gap: var(--space-14);
  min-width: 0;
}

.tree-brand-icon {
  width: 56px;
  height: 56px;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  padding: 4px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

.tree-brand-copy {
  min-width: 0;
}

.tree-brand-copy h1 {
  margin: 0;
  color: var(--jungle-green);
  font-family: "PistonBlack", "Cinzel", "Copperplate", Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 3.3vw, 58px);
  line-height: 0.88;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9),
    0 5px 14px rgba(0, 168, 107, 0.12);
  white-space: nowrap;
}

/* The old motto/subtitle line under the title is intentionally hidden. */
.tree-brand-copy p {
  display: none;
}


/* =========================================================
   6. Top controls
   ========================================================= */

.tree-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: var(--space-10);
  flex-wrap: wrap;
}

.control-block {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.control-block span {
  color: var(--smoky-rose);
  font-size: var(--fs-12);
  font-weight: 800;
  letter-spacing: 0.02em;
}


/* =========================================================
   7. Buttons
   ========================================================= */

.primary-button,
.soft-button,
.ghost-button,
.icon-button {
  border-radius: 999px;
  border: 2px solid transparent;
  font-weight: 800;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.primary-button:hover,
.soft-button:hover,
.ghost-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  padding: 11px 18px;
  background: linear-gradient(180deg, #4bb06f, #39a25f);
  color: white;
  box-shadow: 0 10px 18px rgba(57, 162, 95, 0.24);
}

.soft-button {
  padding: 10px 16px;
  border-color: rgba(156, 46, 53, 0.28);
  background: #fff;
  color: var(--brown-red);
}

.ghost-button {
  padding: 10px 16px;
  border-color: rgba(156, 46, 53, 0.52);
  background: transparent;
  color: var(--brown-red);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-color: rgba(156, 46, 53, 0.62);
  background: #fff;
  color: var(--brown-red);
  font-size: 18px;
}

.primary-button:disabled,
.soft-button:disabled,
.ghost-button:disabled,
.icon-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}


/* =========================================================
   8. Inputs / form fields
   ========================================================= */

input,
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid rgba(156, 46, 53, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

input::placeholder,
textarea::placeholder {
  color: rgba(91, 75, 67, 0.46);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(156, 46, 53, 0.72);
  box-shadow: 0 0 0 4px rgba(156, 46, 53, 0.08);
}

textarea {
  min-height: 84px;
  resize: vertical;
}


/* =========================================================
   9. Floating search overlay
   ========================================================= */

.tree-searchbar {
  position: fixed;
  top: calc(var(--topbar-height) + 16px);
  left: 50%;
  right: auto;
  z-index: 28;
  width: min(880px, calc(100vw - 48px));
  padding: 0;
  transform: translateX(-50%);
  pointer-events: none;
}

.search-main {
  width: 100%;
  max-width: none;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(130px, 150px) minmax(150px, 170px) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(156, 46, 53, 0.18);
  border-radius: 999px;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.72), transparent 38%),
    rgba(245, 239, 217, 0.74);
  box-shadow: 0 12px 28px rgba(79, 47, 39, 0.1);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.search-main input,
.search-main select {
  min-width: 0;
  height: 42px;
  border-radius: 999px;
}

.search-main .soft-button {
  height: 42px;
  padding-top: 0;
  padding-bottom: 0;
  white-space: nowrap;
}

.search-results {
  position: absolute;
  top: 64px;
  left: 50%;
  right: auto;
  width: min(980px, calc(100vw - 48px));
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 6px 12px;
  border: 1px solid rgba(156, 46, 53, 0.16);
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.74), transparent 40%),
    rgba(245, 239, 217, 0.76);
  box-shadow: 0 16px 34px rgba(79, 47, 39, 0.12);
  backdrop-filter: blur(10px);
  transform: translateX(-50%);
  scrollbar-width: thin;
  pointer-events: auto;
}

.search-results[hidden] {
  display: none !important;
}

.search-results button {
  flex: 0 0 230px;
  min-height: 92px;
  display: grid;
  align-content: start;
  gap: 4px;
  margin: 0;
  padding: var(--space-12) var(--space-14);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.search-results button:hover {
  border-color: rgba(156, 46, 53, 0.48);
  box-shadow: 0 10px 22px rgba(79, 47, 39, 0.12);
  transform: translateY(-1px);
}

.search-results strong {
  display: block;
  color: var(--brown-red);
  font-size: var(--fs-14);
  font-weight: 800;
  line-height: 1.15;
}

.search-results span {
  display: block;
  margin-top: 2px;
  color: var(--text-soft);
  font-size: var(--fs-12);
  line-height: 1.25;
}

.search-results small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--fs-11);
}


/* =========================================================
   10. Timeline / canvas
   ========================================================= */

.timeline-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  padding-top: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), transparent 42%),
    linear-gradient(115deg, #ffffff 0%, #fffdf7 48%, #f8f0d9 100%);
}

#timelineCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.card-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}


/* =========================================================
   11. Small map name cards
   ========================================================= */

.person-card {
  position: absolute;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "flag name"
    "flag last"
    "flag date";
  align-items: center;
  gap: 1px 8px;
  padding: 9px 10px;
  border: 1px solid rgba(156, 46, 53, 0.24);
  border-radius: 14px;
  background: rgba(245, 239, 217, 0.92);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  text-align: left;
  backdrop-filter: blur(6px);
  pointer-events: auto;
  animation: cardPop 180ms ease-out both;
}

.person-card:hover {
  border-color: rgba(156, 46, 53, 0.52);
  box-shadow: var(--shadow-md);
}

.person-card.is-selected {
  border-color: rgba(0, 168, 107, 0.66);
  box-shadow: 0 12px 26px rgba(0, 168, 107, 0.14);
}

.person-card-flag {
  grid-area: flag;
  align-self: start;
  font-size: 18px;
}

.person-card-name {
  grid-area: name;
  color: var(--brown-red);
  font-size: var(--fs-13);
  font-weight: 800;
  line-height: 1.05;
}

.person-card-last {
  grid-area: last;
  color: var(--text);
  font-size: var(--fs-13);
  font-weight: 700;
  line-height: 1.05;
}

.person-card-date {
  grid-area: date;
  color: var(--text-soft);
  font-size: var(--fs-11);
  font-weight: 700;
}

@keyframes cardPop {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(6px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}


/* =========================================================
   12. Zoom controls
   ========================================================= */

.zoom-controls {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 24;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.zoom-controls button {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(156, 46, 53, 0.26);
  border-radius: 999px;
  background: white;
  color: var(--brown-red);
  font-weight: 800;
}

.zoom-controls span {
  min-width: 54px;
  color: var(--smoky-rose);
  font-size: var(--fs-13);
  font-weight: 800;
  text-align: center;
}


/* =========================================================
   13. Unattached panel
   ========================================================= */

.unattached-panel {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 24;
  width: 260px;
  max-width: calc(100vw - 36px);
}

.unattached-panel > button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-10);
  padding: 12px 14px;
  border: 2px solid rgba(156, 46, 53, 0.5);
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.95);
  box-shadow: var(--shadow-sm);
  color: var(--brown-red);
  font-weight: 800;
  backdrop-filter: blur(8px);
}

.unattached-panel strong {
  min-width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #46a868;
  color: white;
  font-size: var(--fs-15);
}

.unattached-list {
  max-height: 320px;
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
}

.unattached-list button {
  padding: 10px 12px;
  border: 1px solid rgba(156, 46, 53, 0.18);
  border-radius: 14px;
  background: var(--surface-2);
  text-align: left;
}

.unattached-list span {
  display: block;
  color: var(--brown-red);
  font-size: var(--fs-13);
  font-weight: 800;
}

.unattached-list small {
  display: block;
  margin-top: 3px;
  color: var(--text-soft);
  font-size: var(--fs-12);
}


/* =========================================================
   14. Person drawer / large name card
   ========================================================= */

.person-drawer {
  position: fixed;
  top: 82px;
  right: 16px;
  z-index: 40;
  min-width: 420px;
  width: min(520px, calc(100vw - 24px));
  max-width: min(920px, calc(100vw - 24px));
  max-height: calc(100vh - 110px);
  padding: var(--space-16);
  overflow: auto;
  resize: horizontal;
  border: 3px solid rgba(156, 46, 53, 0.84);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-lg);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: var(--space-16);
  margin-bottom: var(--space-14);
}

.drawer-heading {
  flex: 1;
  min-width: 0;
}

.drawer-heading h2 {
  display: block;
  margin: 0;
  color: var(--brown-red);
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.03em;
  word-break: normal;
  overflow-wrap: anywhere;
}

.drawer-meta {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  padding-bottom: var(--space-14);
  border-bottom: 2px solid rgba(156, 46, 53, 0.22);
}

.drawer-birth-date {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-24);
  font-weight: 900;
  line-height: 1.05;
}

.drawer-birth-place {
  display: block;
  margin: 0;
  color: var(--text);
  font-size: var(--fs-16);
  font-weight: 800;
  line-height: 1.24;
}

.drawer-death-block {
  display: grid;
  gap: 2px;
  margin-top: 4px;
}

.drawer-death-line,
.drawer-death-place {
  margin: 0;
  color: var(--text-soft);
  font-weight: 700;
}

.drawer-death-line {
  font-size: var(--fs-14);
}

.drawer-death-place {
  font-size: var(--fs-13);
}

.drawer-actions {
  display: flex;
  align-items: start;
  gap: 10px;
}

.person-drawer .form-grid,
.person-drawer .form-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.person-drawer .person-name-row {
  grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.person-drawer .relationship-picker-section .form-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.person-drawer .relationship-picker-section select[multiple] {
  min-height: 150px;
}


/* =========================================================
   15. Drawer sections
   ========================================================= */

.drawer-section {
  margin-top: var(--space-18);
  padding: var(--space-14);
  border: 2px solid rgba(156, 46, 53, 0.28);
  border-radius: var(--radius-lg);
  background: rgba(245, 239, 217, 0.38);
}

.drawer-section h3 {
  margin: 0 0 var(--space-12);
  color: var(--jungle-green);
  font-size: var(--fs-16);
  font-weight: 900;
  line-height: 1.1;
}

.person-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-10);
  margin-bottom: 2px;
}

.person-link-row a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(156, 46, 53, 0.22);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--brown-red);
  font-size: var(--fs-13);
  font-weight: 800;
  text-decoration: none;
}

.person-link-row img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}


/* =========================================================
   16. Files / uploads
   ========================================================= */

.file-groups {
  display: grid;
  gap: 12px;
}

.file-group h4 {
  margin: 0 0 8px;
  color: var(--smoky-rose);
  font-size: var(--fs-12);
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.file-button-grid {
  display: grid;
  gap: 8px;
}

.file-button {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(156, 46, 53, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.file-button span {
  font-size: 18px;
}

.file-button strong {
  color: var(--brown-red);
  font-size: var(--fs-13);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.file-button small {
  color: var(--text-soft);
  font-size: var(--fs-11);
  font-weight: 700;
}

.upload-form {
  display: grid;
  gap: 12px;
}

.upload-drop {
  display: grid;
  gap: 4px;
  padding: 16px;
  border: 2px dashed rgba(156, 46, 53, 0.28);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  text-align: center;
}

.upload-drop strong {
  color: var(--brown-red);
  font-size: var(--fs-14);
  font-weight: 900;
}

.upload-drop span {
  color: var(--text-soft);
  font-size: var(--fs-12);
  font-weight: 600;
  line-height: 1.35;
}

.upload-drop.is-dragging {
  border-color: rgba(0, 168, 107, 0.62);
  background: rgba(0, 168, 107, 0.05);
}

.upload-status {
  margin: 0;
  color: var(--smoky-rose);
  font-size: var(--fs-12);
  font-weight: 700;
}


/* =========================================================
   17. Events
   ========================================================= */

.event-list {
  display: grid;
  gap: 10px;
}

.event-card {
  padding: 12px 14px;
  border: 1px solid rgba(156, 46, 53, 0.24);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.95);
}

.event-type {
  display: block;
  color: var(--brown-red);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.1;
}

.event-date {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: var(--fs-14);
  font-weight: 900;
}

.event-place {
  display: block;
  margin-top: 1px;
  color: var(--smoky-rose);
  font-size: var(--fs-12);
  font-weight: 800;
}

.event-title,
.event-note {
  margin: 8px 0 0;
  color: var(--text);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.event-title {
  font-size: var(--fs-14);
  font-weight: 700;
}

.event-note {
  font-size: var(--fs-13);
  font-weight: 500;
}

.add-event-details {
  margin-top: 8px;
}

.add-event-details summary {
  color: var(--brown-red);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

.add-event-details summary::-webkit-details-marker {
  display: none;
}

.add-event-details[open] summary {
  margin-bottom: 12px;
}

.event-extra-block h4 {
  margin: 0 0 10px;
  color: var(--smoky-rose);
  font-size: var(--fs-13);
  font-weight: 900;
}


/* =========================================================
   18. Relationships
   ========================================================= */

.relationship-list {
  display: grid;
  gap: 10px;
}

.relationship-card {
  padding: 12px 14px;
  border: 1px solid rgba(156, 46, 53, 0.24);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.95);
}

.relationship-card strong {
  display: block;
  color: var(--brown-red);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.1;
}

.relationship-card span {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: var(--fs-14);
  font-weight: 800;
  word-break: normal;
  overflow-wrap: anywhere;
}

.relationship-card small {
  display: block;
  margin-top: 5px;
  color: var(--text-soft);
  font-size: var(--fs-12);
  font-weight: 600;
}

.relationship-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.relationship-button:hover {
  border-color: rgba(156, 46, 53, 0.56);
  background: var(--eggshell);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.relationship-picker-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(156, 46, 53, 0.22);
  border-radius: 18px;
  background: rgba(245, 239, 217, 0.32);
}

.relationship-picker-section h3 {
  margin: 0;
  color: var(--jungle-green);
  font-size: var(--fs-16);
  font-weight: 950;
}

.relationship-picker-section p {
  margin: -4px 0 2px;
  color: var(--smoky-rose);
  font-size: var(--fs-12);
  font-weight: 700;
}

.relationship-picker-section small {
  color: var(--muted);
  font-size: var(--fs-11);
  font-weight: 700;
}

.relationship-picker-section select[multiple] {
  min-height: 124px;
  padding: 8px;
  border-radius: 14px;
}

.relationship-picker-section select[multiple] option {
  padding: 6px 7px;
  border-radius: 8px;
}


/* =========================================================
   19. Forms / modal form layout
   ========================================================= */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.compact {
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--smoky-rose);
  font-size: var(--fs-13);
  font-weight: 800;
}

.person-name-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.full-width {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.form-separator {
  width: 100%;
  height: 1px;
  margin: 6px 0 2px;
  border: 0;
  background: linear-gradient(
    to right,
    transparent,
    rgba(156, 46, 53, 0.32),
    transparent
  );
}

.form-section-title {
  margin-top: 2px;
  color: var(--brown-red);
  font-size: var(--fs-14);
  font-weight: 950;
  letter-spacing: 0.01em;
}

.small-muted {
  margin: 0;
  color: var(--text-soft);
  font-size: var(--fs-12);
  font-weight: 600;
}

.form-error {
  margin: 8px 0 0;
  color: var(--brown-red);
  font-size: var(--fs-12);
  font-weight: 800;
}


/* =========================================================
   20. Modals / login
   ========================================================= */

.modal-backdrop,
.login-overlay,
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(35, 26, 23, 0.34);
  backdrop-filter: blur(8px);
}

.modal-backdrop[hidden],
.login-overlay[hidden],
.lightbox[hidden] {
  display: none !important;
}

.modal-card,
.login-card {
  position: absolute;
  left: 50%;
  width: min(760px, calc(100vw - 32px));
  border: 3px solid rgba(156, 46, 53, 0.9);
  border-radius: 34px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
}

.modal-card {
  top: 30px;
  max-height: calc(100vh - 60px);
  overflow: auto;
  padding: 18px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: var(--space-16);
  margin-bottom: var(--space-14);
  padding-bottom: var(--space-14);
  border-bottom: 2px solid rgba(156, 46, 53, 0.2);
}

.modal-header h2 {
  margin: 0;
  color: var(--brown-red);
  font-size: var(--fs-24);
  font-weight: 900;
}

.login-card {
  top: 50%;
  width: min(420px, calc(100vw - 32px));
  padding: 26px;
  text-align: center;
  transform: translate(-50%, -50%);
}

.login-card img {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}

.login-card h2 {
  margin: 0 0 8px;
  color: var(--brown-red);
  font-size: var(--fs-24);
  font-weight: 900;
}

.login-card p {
  margin: 0 0 14px;
  color: var(--text-soft);
  font-size: var(--fs-14);
  line-height: 1.4;
}


/* =========================================================
   21. Lightbox
   ========================================================= */

.lightbox {
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 20px;
}

.lightbox-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(156, 46, 53, 0.24);
  border-radius: 20px 20px 0 0;
  background: rgba(255, 255, 255, 0.96);
}

.lightbox-bar strong {
  color: var(--brown-red);
  font-size: var(--fs-15);
  font-weight: 900;
}

.lightbox-bar > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lightbox-body {
  min-height: 0;
  padding: 18px;
  overflow: auto;
  border: 1px solid rgba(156, 46, 53, 0.24);
  border-top: 0;
  border-radius: 0 0 20px 20px;
  background: rgba(255, 255, 255, 0.98);
}

.lightbox-body img,
.lightbox-body iframe {
  width: 100%;
  max-width: 100%;
  border: 1px solid rgba(156, 46, 53, 0.16);
  border-radius: 16px;
  background: white;
}

.lightbox-body iframe {
  min-height: 70vh;
}

.download-card {
  display: grid;
  gap: 12px;
  justify-items: start;
}

.download-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: var(--fs-14);
}


/* =========================================================
   22. Footer credit
   ========================================================= */

.site-credit {
  position: fixed;
  left: 50%;
  bottom: 10px;
  z-index: 20;
  padding: 5px 11px;
  border: 1px solid rgba(156, 46, 53, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--smoky-rose);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  transform: translateX(-50%);
  pointer-events: none;
  backdrop-filter: blur(8px);
}


/* =========================================================
   23. Responsive
   ========================================================= */

@media (max-width: 1020px) {
  :root {
    --topbar-height: 148px;
  }

  .tree-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .tree-controls {
    justify-content: flex-start;
  }

  .person-drawer {
    top: 94px;
    right: 9px;
    width: min(520px, calc(100vw - 18px));
  }
}

@media (max-width: 720px) {
  body {
    overflow: auto;
  }

  :root {
    --topbar-height: auto;
  }

  .tree-app {
    grid-template-rows: auto auto 1fr;
  }

  .tree-topbar {
    padding: 14px;
  }

  .tree-brand-icon {
    width: 46px;
    height: 46px;
  }

  .tree-brand-copy h1 {
    font-size: 30px;
    letter-spacing: 0.07em;
    white-space: normal;
  }

  .tree-searchbar {
    position: static;
    width: 100%;
    padding: 0 14px 12px;
    transform: none;
    pointer-events: auto;
  }

  .search-main {
    grid-template-columns: 1fr;
    width: 100%;
    border-radius: 22px;
  }

  .search-results {
    position: static;
    width: 100%;
    display: grid;
    overflow: visible;
    transform: none;
  }

  .search-results button {
    flex: unset;
  }

  .timeline-wrap {
    min-height: 68vh;
    padding-top: 0;
  }

  .person-drawer {
    position: fixed;
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 10px;
    min-width: 0;
    width: auto;
    max-width: none;
    max-height: 74vh;
    resize: none;
    border-radius: 26px;
  }

  .drawer-heading h2 {
    font-size: 22px;
  }

  .drawer-birth-date {
    font-size: 20px;
  }

  .drawer-birth-place {
    font-size: 15px;
  }

  .modal-card {
    top: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    padding: 14px;
    border-radius: 28px;
  }

  .form-grid,
  .person-name-row,
  .person-drawer .person-name-row {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .zoom-controls {
    right: 10px;
    bottom: 10px;
  }

  .unattached-panel {
    left: 10px;
    bottom: 10px;
    width: 220px;
  }

  .lightbox {
    padding: 10px;
  }

  .lightbox-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .lightbox-bar > div {
    justify-content: flex-end;
  }
}
