/* ============================================================
   Stammbaum — design system
   Vintage beige · dark blue ink · bright sand · Instrument Serif + Lexend
   ============================================================ */

@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  src: url('/fonts/instrument-serif-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  src: url('/fonts/instrument-serif-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  src: url('/fonts/instrument-serif-latin-400-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  src: url('/fonts/instrument-serif-latin-ext-400-italic.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-weight: 300 600;
  src: url('/fonts/lexend-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-weight: 300 600;
  src: url('/fonts/lexend-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ink: #1b2a4a;
  --ink-deep: #101b33;
  --ink-soft: #3d4d73;
  --sand: #d9b36c;
  --sand-bright: #e9cf9c;
  --sand-faint: #f2e3c4;
  --paper: #f4edda;
  --paper-light: #faf6ea;
  --paper-deep: #e9dfc4;
  --sepia: #4d4232;
  --sepia-faint: #8a7c66;
  --brick: #9c4a3c;
  --forest: #4a6b52;
  --olive: #8a7a3c;
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --sans: 'Lexend', system-ui, -apple-system, sans-serif;
  --radius: 10px;
  --shadow: 0 10px 30px -12px rgba(16, 27, 51, .25);
  --shadow-sm: 0 3px 10px -4px rgba(16, 27, 51, .18);
  --hairline: 1px solid var(--paper-deep);
}

* { box-sizing: border-box; }

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

body {
  background: var(--paper);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(217, 179, 108, .14), transparent 60%),
    repeating-linear-gradient(0deg, rgba(74, 66, 50, .022) 0 1px, transparent 1px 3px);
  color: var(--sepia);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--sand-bright); color: var(--ink-deep); }

a { color: var(--ink); }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 400; color: var(--ink); margin: 0 0 .5em; line-height: 1.15; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

.muted { color: var(--sepia-faint); }
.small { font-size: 13px; }
.micro {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--sepia-faint);
}

/* ---------------- buttons ---------------- */
.btn {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13.5px;
  letter-spacing: .02em;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 18px;
  cursor: pointer;
  transition: all .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  background: none;
  line-height: 1.2;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--ink); color: var(--paper-light); box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--ink-deep); transform: translateY(-1px); }

.btn-sand { background: var(--sand); color: var(--ink-deep); }
.btn-sand:hover:not(:disabled) { background: var(--sand-bright); }

.btn-ghost { border-color: var(--paper-deep); color: var(--ink); background: transparent; }
.btn-ghost:hover:not(:disabled) { border-color: var(--sand); background: var(--paper-light); }

.btn-danger-ghost { border-color: transparent; color: var(--brick); }
.btn-danger-ghost:hover:not(:disabled) { background: rgba(156, 74, 60, .08); border-color: rgba(156, 74, 60, .3); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }

/* ---------------- inputs ---------------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--sepia-faint);
  margin-bottom: 5px;
}
.input, select.input, textarea.input {
  width: 100%;
  font-family: var(--sans);
  font-weight: 300;
  font-size: 14.5px;
  color: var(--sepia);
  background: var(--paper-light);
  border: 1px solid var(--paper-deep);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--sand); box-shadow: 0 0 0 3px rgba(217, 179, 108, .25); }
textarea.input { resize: vertical; min-height: 80px; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238a7c66' fill='none' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* ---------------- top bar ---------------- */
.topbar {
  background: var(--ink);
  color: var(--paper-light);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 26px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 2px solid var(--sand);
  box-shadow: 0 2px 12px rgba(16, 27, 51, .25);
}
.wordmark {
  font-family: var(--serif);
  font-style: italic;
  font-size: 24px;
  color: var(--paper-light);
  text-decoration: none;
  letter-spacing: .02em;
  white-space: nowrap;
}
.wordmark em { color: var(--sand); font-style: italic; }
.topnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topnav a {
  color: rgba(250, 246, 234, .78);
  text-decoration: none;
  font-size: 12.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 7px;
  white-space: nowrap;
  transition: all .15s;
}
.topnav a:hover { color: var(--paper-light); background: rgba(217, 179, 108, .14); }
.topnav a.active { color: var(--ink-deep); background: var(--sand); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.role-badge {
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-deep);
  background: var(--sand);
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.user-chip { display: flex; align-items: center; gap: 8px; color: rgba(250, 246, 234, .85); font-size: 13px; }

/* ---------------- cards / panels ---------------- */
.panel {
  background: var(--paper-light);
  border: 1px solid var(--paper-deep);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-pad { padding: 22px 26px; }

.ledger { position: relative; }
.ledger::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background-image: repeating-linear-gradient(0deg, rgba(74, 66, 50, .015) 0 1px, transparent 1px 3px);
}

/* ---------------- modals ---------------- */
.veil {
  position: fixed;
  inset: 0;
  background: rgba(16, 27, 51, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 20px 20px;
  z-index: 100;
  overflow-y: auto;
  animation: veil-in .18s ease;
}
@keyframes veil-in { from { opacity: 0; } }
.modal {
  background: var(--paper-light);
  border-radius: 14px;
  box-shadow: 0 24px 60px -12px rgba(16, 27, 51, .45);
  border: 1px solid var(--paper-deep);
  width: 100%;
  max-width: 640px;
  animation: modal-in .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes modal-in { from { transform: translateY(14px) scale(.985); opacity: 0; } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px 14px;
  border-bottom: var(--hairline);
}
.modal-head h2 { margin: 0; font-size: 24px; }
.modal-body { padding: 20px 24px 6px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px 20px;
  border-top: var(--hairline);
  margin-top: 14px;
}
.icon-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--sepia-faint);
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--paper-deep); color: var(--ink); }

/* ---------------- toasts ---------------- */
.toasts {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--paper-light);
  border: 1px solid var(--paper-deep);
  border-left: 4px solid var(--sand);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 11px 18px;
  font-size: 14px;
  max-width: 480px;
  animation: toast-in .25s ease;
}
.toast.ok { border-left-color: var(--forest); }
.toast.err { border-left-color: var(--brick); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ---------------- medallions ---------------- */
.medallion {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--sand-faint);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(217, 179, 108, .55);
  overflow: hidden;
}
.medallion img { width: 100%; height: 100%; object-fit: cover; }
.medallion.lg { width: 72px; height: 72px; font-size: 30px; }
.medallion.sm { width: 32px; height: 32px; font-size: 14px; }

/* ---------------- tables ---------------- */
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--sepia-faint);
  padding: 10px 12px;
  border-bottom: 2px solid var(--paper-deep);
}
table.list td { padding: 11px 12px; border-bottom: var(--hairline); vertical-align: middle; }
table.list tr:hover td { background: rgba(217, 179, 108, .08); }
table.list tr.clickable { cursor: pointer; }

/* ---------------- badges ---------------- */
.badge {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge.pending { background: rgba(138, 122, 60, .15); color: var(--olive); }
.badge.approved { background: rgba(74, 107, 82, .14); color: var(--forest); }
.badge.rejected { background: rgba(156, 74, 60, .12); color: var(--brick); }
.badge.neutral { background: var(--paper-deep); color: var(--sepia-faint); }

/* ---------------- auth screens ---------------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 16px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--paper-light);
  border: 1px solid var(--paper-deep);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 38px 36px 30px;
  position: relative;
}
.auth-card::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 10%;
  right: 10%;
  height: 3px;
  background: var(--sand);
  border-radius: 3px;
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .wordmark { color: var(--ink); font-size: 34px; display: block; }
.auth-brand .wordmark em { color: var(--sand); }
.auth-brand .tagline { font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--sepia-faint); margin-top: 6px; }
.auth-alt { text-align: center; margin-top: 18px; font-size: 13.5px; }
.auth-alt a { color: var(--ink); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }

/* ---------------- layout ---------------- */
.page { padding: 28px 30px 60px; max-width: 1200px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 32px; }
.page-head .sub { color: var(--sepia-faint); font-size: 14px; margin-top: 2px; }

/* ---------------- tree ---------------- */
.tree-stage {
  position: fixed;
  inset: 60px 0 0 0;
  background:
    radial-gradient(ellipse 70% 45% at 50% -8%, rgba(217, 179, 108, .12), transparent 60%),
    var(--paper);
  overflow: hidden;
}
.tree-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  user-select: none;
}
.tree-canvas-el {
  position: absolute;
  inset: 0;
  cursor: grab;
  touch-action: none;
}
.tree-canvas-el:active { cursor: grabbing; }
.tree-hitlayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.tree-hit {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  border-radius: 12px;
}
.tree-hit.hover { outline: 2px solid var(--sand); outline-offset: 2px; }
.tree-collapse {
  position: absolute;
  pointer-events: auto;
  border: none;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper-light);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 5px rgba(16, 27, 51, .3);
  transition: background .15s, transform .15s;
}
.tree-collapse:hover { background: var(--sand); color: var(--ink-deep); transform: scale(1.12); }

/* toolbar */
.tree-toolbar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  align-items: center;
  background: rgba(250, 246, 234, .92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--paper-deep);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 6px 8px;
  z-index: 8;
  max-width: calc(100vw - 32px);
}
.tt-sep { width: 1px; height: 20px; background: var(--paper-deep); margin: 0 4px; flex-shrink: 0; }
.tree-toolbar .btn-sm { min-width: 34px; justify-content: center; }
#tt-z-label { min-width: 52px; font-variant-numeric: tabular-nums; }

/* person search dropdown */
.tt-search { position: relative; }
.tt-q {
  width: 200px;
  background: var(--paper-light);
  border: 1px solid var(--paper-deep);
  border-radius: 8px;
  padding: 7px 12px;
  font-family: var(--sans);
  font-weight: 300;
  font-size: 13.5px;
  color: var(--sepia);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.tt-q:focus { border-color: var(--sand); box-shadow: 0 0 0 3px rgba(217, 179, 108, .22); }
.tt-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 280px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--paper-light);
  border: 1px solid var(--paper-deep);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 4px;
}
.tt-result {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 7px;
  padding: 8px 10px;
  font-family: var(--sans);
  cursor: pointer;
}
.tt-result:hover { background: var(--paper-deep); }
.tt-r-name { font-family: var(--serif); font-size: 15px; color: var(--ink); }
.tt-r-years { font-size: 11.5px; color: var(--sepia-faint); white-space: nowrap; }
.tt-empty { padding: 12px; font-size: 13px; color: var(--sepia-faint); text-align: center; }

/* legend (bottom-left) */
.tree-legend {
  position: absolute;
  left: 18px;
  bottom: 16px;
  display: flex;
  gap: 14px;
  z-index: 7;
  background: rgba(250, 246, 234, .88);
  backdrop-filter: blur(6px);
  border: 1px solid var(--paper-deep);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--sepia-faint);
}
.tl-item { display: inline-flex; align-items: center; gap: 6px; }
.tl-swatch { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--sand); }
.tl-swatch.living { background: var(--sand-faint); }
.tl-swatch.dead { background: var(--paper-deep); border-color: var(--paper-deep); }

.tree-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--sepia-faint);
  background: rgba(250, 246, 234, .88);
  backdrop-filter: blur(6px);
  border: 1px solid var(--paper-deep);
  border-radius: 20px;
  padding: 5px 14px;
  z-index: 7;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 240px);
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ---------------- person modal ---------------- */
.person-hero { display: flex; gap: 18px; align-items: center; margin-bottom: 18px; }
.person-hero h2 { margin: 0; font-size: 27px; }
.person-hero .vitals { font-size: 13.5px; color: var(--sepia-faint); letter-spacing: .06em; }
.person-section { margin: 18px 0; }
.person-section > .micro { display: block; margin-bottom: 8px; border-bottom: var(--hairline); padding-bottom: 6px; }
.family-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: var(--hairline);
  border-radius: 9px;
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--paper);
  transition: border-color .15s;
}
.family-row:hover { border-color: var(--sand); }
.family-row .role-tag { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--sepia-faint); font-weight: 500; }
.family-row .kids { font-size: 12.5px; color: var(--sepia-faint); margin-left: auto; white-space: nowrap; }
.spouse-link { text-decoration: none; color: var(--ink); font-weight: 500; }
.kid-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border: var(--hairline);
  border-radius: 20px;
  padding: 3px 10px 3px 4px;
  margin: 0 6px 6px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  transition: border-color .15s;
}
.kid-chip:hover { border-color: var(--sand); }

/* ---------------- diff / review ---------------- */
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.diff-col { border: var(--hairline); border-radius: 9px; padding: 12px 14px; background: var(--paper); }
.diff-col h4 { margin: 0 0 8px; font-size: 16px; }
.diff-col .micro { display: block; margin-bottom: 10px; }
.diff-row { display: flex; gap: 8px; padding: 3px 0; font-size: 13.5px; }
.diff-row .k { color: var(--sepia-faint); width: 92px; flex-shrink: 0; font-size: 12px; padding-top: 1px; }
.diff-row .v { flex: 1; word-break: break-word; }
.diff-row .v.empty { color: var(--sepia-faint); font-style: italic; }
.diff-row.changed .v { background: rgba(217, 179, 108, .22); border-radius: 4px; padding: 0 4px; }

/* ---------------- stats ---------------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  background: var(--paper-light);
  border: var(--hairline);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat .num { font-family: var(--serif); font-size: 30px; color: var(--ink); line-height: 1; }
.stat .lbl { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--sepia-faint); margin-top: 6px; font-weight: 500; }

/* ---------------- search ---------------- */
.searchbox { position: relative; }
.searchbox input {
  width: 260px;
  background: rgba(250, 246, 234, .12);
  border: 1px solid rgba(250, 246, 234, .25);
  color: var(--paper-light);
  border-radius: 8px;
  padding: 7px 12px 7px 32px;
  font-family: var(--sans);
  font-weight: 300;
  font-size: 13.5px;
  outline: none;
  transition: all .15s;
}
.searchbox input::placeholder { color: rgba(250, 246, 234, .5); }
.searchbox input:focus { background: var(--paper-light); color: var(--sepia); border-color: var(--sand); }
.searchbox .s-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: rgba(250, 246, 234, .55); font-size: 13px; pointer-events: none; }
.searchbox input:focus + .s-icon { color: var(--sepia-faint); }
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--paper-light);
  border: 1px solid var(--paper-deep);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 50;
  padding: 6px;
}
.search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: var(--sepia);
}
.search-result:hover { background: var(--paper-deep); }
.search-result .sr-name { font-family: var(--serif); font-size: 15px; color: var(--ink); }
.search-result .sr-years { font-size: 12px; color: var(--sepia-faint); }

/* ---------------- empty states ---------------- */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--sepia-faint);
}
.empty .big { font-family: var(--serif); font-style: italic; font-size: 26px; color: var(--ink); margin-bottom: 8px; }

/* ---------------- print ---------------- */
.print-hidden { }
@media print {
  body { background: #fff; }
  .topbar, .tree-toolbar, .toasts, .veil, .print-hidden { display: none !important; }
  .page { max-width: none; padding: 0; }
  .panel { box-shadow: none; border-color: #ccc; }
  .print-cover { text-align: center; padding: 40px 0 10px; border-bottom: 3px double #1b2a4a; margin-bottom: 24px; }
  .print-cover h1 { font-size: 40px; margin: 0; }
  .print-cover .tagline { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: #666; margin-top: 8px; }
  .print-avoid-break { break-inside: avoid; page-break-inside: avoid; }
}

/* ---------------- misc ---------------- */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--paper-deep);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-load { display: flex; align-items: center; justify-content: center; min-height: 50vh; gap: 10px; color: var(--sepia-faint); }

.divider { border: none; border-top: var(--hairline); margin: 18px 0; }

.pill-group { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--paper-deep);
  background: transparent;
  color: var(--sepia-faint);
  cursor: pointer;
  transition: all .15s;
}
.filter-pill:hover { border-color: var(--sand); color: var(--ink); }
.filter-pill.active { background: var(--ink); border-color: var(--ink); color: var(--paper-light); }

.msg-banner {
  border-radius: 9px;
  padding: 12px 16px;
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid;
}
.msg-banner.info { background: rgba(217, 179, 108, .12); border-color: rgba(217, 179, 108, .5); color: var(--olive); }
.msg-banner.err { background: rgba(156, 74, 60, .08); border-color: rgba(156, 74, 60, .35); color: var(--brick); }

/* ============================================================
   Hamburger + megamenu (small screens)
   ============================================================ */
.hamburger {
  display: none;
  background: none;
  border: 1px solid rgba(250, 246, 234, .3);
  border-radius: 8px;
  width: 42px;
  height: 38px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  transition: border-color .15s;
}
.hamburger:hover { border-color: var(--sand); }
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--paper-light);
  transition: transform .25s ease, opacity .2s ease;
  transform-origin: center;
}
.topbar.menu-open .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.topbar.menu-open .hamburger span:nth-child(2) { opacity: 0; }
.topbar.menu-open .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* megamenu panel — hidden by default, slides down from the topbar */
.megamenu {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 39;
  background: var(--paper-light);
  border-bottom: 2px solid var(--sand);
  box-shadow: 0 18px 40px -18px rgba(16, 27, 51, .35);
  padding: 18px 26px 20px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  transform: translateY(-12px);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s ease, opacity .2s ease;
}
.megamenu[aria-hidden="false"] {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.megamenu-inner {
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}
.mm-tile {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--paper-deep);
  border-radius: 12px;
  background: var(--paper);
  text-decoration: none;
  color: var(--sepia);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.mm-tile:hover { border-color: var(--sand); background: var(--paper-light); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.mm-tile.active { border-color: var(--sand); background: var(--sand-faint); }
.mm-icon {
  font-size: 22px;
  line-height: 1;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--sand-faint);
  border: 1px solid rgba(217, 179, 108, .5);
  border-radius: 10px;
  flex-shrink: 0;
}
.mm-body { display: flex; flex-direction: column; gap: 3px; }
.mm-title { font-family: var(--serif); font-size: 18px; color: var(--ink); line-height: 1.2; }
.mm-desc { font-size: 12.5px; color: var(--sepia-faint); line-height: 1.45; }
.mm-foot {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: var(--hairline);
  font-size: 13px;
  color: var(--sepia-faint);
}
.mm-foot .role-badge { margin-right: auto; }

/* responsive: hamburger on smaller screens, hide inline links */
@media (max-width: 900px) {
  .hamburger { display: inline-flex; }
  .topnav { display: none; }
  .user-chip { display: none; }
  .topbar { gap: 14px; padding: 0 18px; }
}
@media (min-width: 901px) {
  .megamenu { display: none; }
}

/* ---------------- import proposals ---------------- */
.proposal-card {
  border: var(--hairline);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--paper);
  transition: border-color .15s;
}
.proposal-card:hover { border-color: var(--sand); }
.proposal-card input[type="radio"] { accent-color: var(--ink); margin-right: 4px; }
.proposal-card pre {
  background: var(--paper-light);
  border: var(--hairline);
  border-radius: 8px;
  padding: 8px 10px;
  max-height: 160px;
  overflow: auto;
}

/* ---------------- portraits ---------------- */
.medallion img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait-upload {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  border: 2px solid var(--paper-light);
  transition: transform .15s;
}
.portrait-upload:hover { transform: scale(1.1); background: var(--ink-deep); }


/* ---------------- relationship editor + audit ---------------- */
.rel-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 4px 0 8px; }
.rel-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--paper); border: var(--hairline);
  border-radius: 20px; padding: 2px 10px 2px 3px;
}
.rel-chip .rel-name { font-size: 13px; color: var(--ink); }
.rel-x {
  background: none; border: none; cursor: pointer;
  color: var(--sepia-faint); font-size: 11px; padding: 2px 3px;
  border-radius: 50%;
}
.rel-x:hover { color: var(--brick); background: rgba(156, 74, 60, .1); }
.rel-fam { border: var(--hairline); border-radius: 9px; padding: 10px 12px; margin-bottom: 10px; background: var(--paper); }
.rel-slot { display: inline-flex; align-items: center; gap: 8px; margin-right: 18px; }
.audit-row {
  display: flex; gap: 8px; align-items: baseline;
  padding: 6px 0; border-bottom: var(--hairline);
  flex-wrap: wrap;
}
.audit-row .small:first-child { flex-shrink: 0; }
