/* ====================================================================
   Family OS · משפחה חכמה — Preview Stylesheet
   Warm, modern, Hebrew RTL. Terracotta + sage + cream.
   ==================================================================== */

:root {
  /* Brand palette */
  --terracotta:        #c2622e;
  --terracotta-2:      #a44e22;
  --terracotta-soft:   #e8a07a;
  --terracotta-tint:   #f7e6d8;
  --sage:              #5b8b78;
  --sage-soft:         #b6cfc2;
  --plum:              #b08bbf;
  --gold:              #d6a84a;

  /* Neutrals (warm) */
  --bg:                #fdf6f0;
  --bg-2:              #faeee2;
  --card:              #ffffff;
  --card-2:            #fffaf4;
  --border:            #efe2d3;
  --border-strong:     #e3cfb8;
  --text:              #2d2416;
  --text-2:            #4a3d2c;
  --muted:             #8c7b6e;
  --muted-2:           #b5a594;

  /* Status */
  --ok:                #2f8a5d;
  --ok-soft:           #d8efe1;
  --warn:              #b5701f;
  --warn-soft:         #fbe7cc;
  --danger:            #b8463a;
  --danger-soft:       #f6dad6;
  --info:              #3a72a3;
  --info-soft:         #dceaf5;

  /* Shape */
  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(70,40,20,.06);
  --shadow:    0 2px 10px rgba(70,40,20,.07);
  --shadow-lg: 0 8px 28px rgba(70,40,20,.10);

  /* Layout */
  --sidebar-w: 260px;
  --topbar-h:  72px;

  /* Font stack — Heebo if available, system fallback */
  --font:
    "Heebo",
    "Assistant",
    "Arial Hebrew",
    -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  direction: rtl;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
ul { list-style: none; padding: 0; margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
p  { margin: 0; }

/* ====================================================================
   APP SHELL — fixed sidebar on the right (RTL); main fills the rest.
   ==================================================================== */
.app-shell {
  min-height: 100vh;
  position: relative;
}

/* ====================================================================
   SIDEBAR (fixed to the right in RTL)
   ==================================================================== */
.sidebar {
  position: fixed;
  top: 0;
  inset-inline-start: 0; /* inline-start = right edge in RTL */
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, #fffaf4 0%, #fdf6f0 100%);
  border-inline-end: 1px solid var(--border);
  padding: 22px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--terracotta), var(--terracotta-soft));
  display: grid; place-items: center;
  color: #fff;
  box-shadow: var(--shadow);
}
.brand-title {
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
}
.brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-2);
  position: relative;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.nav-link:hover {
  background: var(--terracotta-tint);
  color: var(--terracotta-2);
}
.nav-link.active {
  background: linear-gradient(90deg, var(--terracotta) 0%, var(--terracotta-2) 100%);
  color: #fff;
  box-shadow: var(--shadow);
}
.nav-icon { font-size: 16px; width: 22px; text-align: center; }
.nav-badge {
  margin-inline-start: auto;
  background: var(--gold);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.nav-link.active .nav-badge { background: #fff; color: var(--terracotta-2); }

.sidebar-footer {
  margin-top: auto;
}
.dna-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.dna-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.dna-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
  color: var(--text-2);
}
.dna-badge {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--muted);
}
.dna-badge.ok {
  background: var(--ok-soft);
  border-color: #c5e3d0;
  color: var(--ok);
}

/* ====================================================================
   MAIN AREA — pushed away from the fixed sidebar
   ==================================================================== */
.main {
  margin-inline-start: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(253, 246, 240, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  padding: 0 24px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tree-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px 6px 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.tree-selector:hover { border-color: var(--border-strong); }
.tree-color {
  width: 10px; height: 10px; border-radius: 999px;
  display: inline-block;
}
.tree-chev { color: var(--muted); }

.quick-switch {
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow-sm);
}
.qs-btn {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--text-2);
}
.qs-btn.active {
  background: var(--terracotta);
  color: #fff;
}

.topbar-center { min-width: 0; }
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  max-width: 560px;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
}
.search:focus-within {
  border-color: var(--terracotta-soft);
  box-shadow: 0 0 0 4px rgba(194, 98, 46, 0.10);
}
.search input {
  border: 0;
  outline: 0;
  flex: 1;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
}
.search input::placeholder { color: var(--muted-2); }
.search-icon { color: var(--muted); }
.search-kbd {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 6px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--terracotta);
  color: #fff;
  box-shadow: 0 2px 6px rgba(194,98,46,0.30);
}
.btn-primary:hover { background: var(--terracotta-2); }
.btn-ghost {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--bg-2); }
.icon-btn {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 38px; height: 38px;
  font-size: 16px;
  color: var(--text-2);
}
.icon-btn:hover { background: var(--bg-2); }
.icon-btn .dot {
  position: absolute;
  top: 8px; left: 8px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--terracotta);
  border: 2px solid var(--card);
}
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, var(--sage), #4f7b69);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

/* ====================================================================
   CONTENT
   ==================================================================== */
.content {
  padding: 24px 28px 56px;
  display: block;
}
.view {
  display: none;
  animation: fadeIn .25s ease;
}
.view.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 26px; font-weight: 800; }
.page-sub {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 6px;
  max-width: 720px;
}
.page-head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.branch-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-inline-start: 6px;
  margin-inline-end: 2px;
}

/* ====================================================================
   STATS GRID (dashboard cards)
   ==================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-card .stat-icon {
  position: absolute;
  top: 14px; left: 14px;
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 17px;
  background: var(--terracotta-tint);
  color: var(--terracotta-2);
}
.stat-card.green .stat-icon  { background: #dcebe4; color: var(--sage); }
.stat-card.plum  .stat-icon  { background: #ede0f1; color: var(--plum); }
.stat-card.gold  .stat-icon  { background: #f5e8c8; color: #a78327; }
.stat-card.blue  .stat-icon  { background: var(--info-soft); color: var(--info); }
.stat-card.red   .stat-icon  { background: var(--danger-soft); color: var(--danger); }

.stat-card .stat-label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}
.stat-card .stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  margin-top: 8px;
  letter-spacing: -0.02em;
}
.stat-card .stat-delta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}
.stat-card .stat-delta.up { color: var(--ok); }
.stat-card .stat-delta.down { color: var(--danger); }

/* ====================================================================
   GENERIC CARD
   ==================================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-link {
  font-size: 12.5px;
  color: var(--terracotta);
  font-weight: 600;
}
.card-link:hover { color: var(--terracotta-2); }

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}
@media (max-width: 1050px) {
  .grid-2col { grid-template-columns: 1fr; }
}

/* List items inside cards */
.event-list li,
.birthday-list li,
.draft-list li,
.quality-list li,
.contacts-list li {
  padding: 11px 0;
  border-bottom: 1px dashed var(--border);
  display: flex;
  gap: 12px;
  align-items: center;
}
.event-list li:last-child,
.birthday-list li:last-child,
.draft-list li:last-child,
.quality-list li:last-child,
.contacts-list li:last-child { border-bottom: 0; }

.event-list .ev-date {
  background: var(--terracotta-tint);
  color: var(--terracotta-2);
  border-radius: 10px;
  width: 52px;
  text-align: center;
  padding: 6px 0;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.1;
}
.event-list .ev-date small { display: block; font-size: 10px; font-weight: 600; color: var(--terracotta-2); opacity: .8; }
.event-list .ev-body { flex: 1; min-width: 0; }
.event-list .ev-title { font-weight: 700; color: var(--text); }
.event-list .ev-meta  { font-size: 12.5px; color: var(--muted); }
.event-list .ev-rsvp  { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.ev-rsvp.confirmed { background: var(--ok-soft); color: var(--ok); }
.ev-rsvp.invited   { background: var(--info-soft); color: var(--info); }
.ev-rsvp.maybe     { background: var(--warn-soft); color: var(--warn); }

.birthday-list .bd-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sage), #4c7868);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 13px;
}
.birthday-list .bd-name { font-weight: 700; }
.birthday-list .bd-meta { font-size: 12.5px; color: var(--muted); }
.birthday-list .bd-day {
  margin-inline-start: auto;
  font-size: 12px;
  color: var(--terracotta-2);
  background: var(--terracotta-tint);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
}

.draft-list .dr-icon {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--terracotta-tint);
  color: var(--terracotta-2);
  border-radius: 8px;
  font-size: 14px;
}
.draft-list .dr-body { flex: 1; }
.draft-list .dr-title { font-weight: 700; }
.draft-list .dr-meta { font-size: 12.5px; color: var(--muted); }
.draft-list .dr-actions { display: flex; gap: 4px; }
.draft-list .dr-actions button {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-2);
}
.draft-list .dr-actions .approve { background: var(--ok-soft); color: var(--ok); border-color: #b3dac0; }
.draft-list .dr-actions .reject  { background: var(--danger-soft); color: var(--danger); border-color: #ecc6c0; }

.quality-list .q-icon {
  width: 28px; height: 28px;
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 13px;
}
.quality-list .q-body { flex: 1; }
.quality-list .q-name { font-weight: 700; }
.quality-list .q-missing { font-size: 12.5px; color: var(--muted); }
.quality-list .q-fix {
  border: 0; background: transparent; color: var(--terracotta);
  font-weight: 700; font-size: 12.5px;
}

/* ====================================================================
   TREE VIEW (SVG)
   ==================================================================== */
.tree-canvas {
  padding: 18px;
}
.tree-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 14px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-2);
}
.zoom { margin-inline-start: auto; color: var(--muted); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.zoom-btn {
  width: 24px; height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
}

.tree-svg-wrap {
  width: 100%;
  overflow: auto;
  background:
    radial-gradient(circle at 1px 1px, rgba(140,123,110,0.18) 1px, transparent 0) 0 0 / 22px 22px,
    linear-gradient(180deg, #fffaf4, #fdf6f0);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
}
.tree-svg-wrap svg { display: block; margin: 0 auto; }

.tree-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.tree-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-box {
  width: 14px; height: 14px;
  border-radius: 4px;
  background: var(--terracotta);
}
.legend-box.solid  { background: var(--terracotta); }
.legend-box.dashed { background: transparent; border: 2px dashed var(--terracotta); }
.legend-box.warn   { background: var(--warn); }
.legend-box.dup    { background: var(--gold); }
.legend-box.link   { background: var(--sage); }

/* SVG node styles */
.tree-node-rect {
  fill: #fff;
  stroke: var(--border-strong);
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 4px rgba(70,40,20,0.08));
}
.tree-node-rect.draft { stroke-dasharray: 5 4; stroke: var(--terracotta); fill: #fff8f1; }
.tree-node-rect.warn  { stroke: var(--warn); fill: #fff5e6; }
.tree-node-rect.dup   { stroke: var(--gold); fill: #fdf3da; }
.tree-node-rect.link  { stroke: var(--sage); fill: #ecf3ef; stroke-dasharray: 2 3; }

.tree-node-name { font-weight: 700; font-size: 13px; fill: var(--text); }
.tree-node-meta { font-size: 11px; fill: var(--muted); }
.tree-link-line {
  stroke: var(--border-strong);
  stroke-width: 1.6;
  fill: none;
}
.tree-link-line.draft { stroke-dasharray: 4 4; stroke: var(--terracotta-soft); }

/* ====================================================================
   TILES (Family cards)
   ==================================================================== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.filter {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 600;
}
.filter:hover { background: var(--bg-2); }
.filter.active {
  background: var(--terracotta);
  color: #fff;
  border-color: var(--terracotta);
}

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 4px; height: 100%;
  background: var(--branch-color, var(--terracotta));
  border-radius: var(--radius) 0 0 var(--radius);
}
.tile-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.tile-head h3 {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
}
.tile-side {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.tile-row {
  font-size: 12.5px;
  color: var(--muted);
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tile-row b { color: var(--text-2); font-weight: 600; }
.tile-children {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tile-child {
  background: var(--bg-2);
  color: var(--text-2);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tile-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.tile-alert {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.alert-bd    { background: var(--terracotta-tint); color: var(--terracotta-2); }
.alert-missing { background: var(--warn-soft); color: var(--warn); }
.alert-rsvp  { background: var(--info-soft); color: var(--info); }
.alert-bm    { background: #f5e8c8; color: #a78327; }

/* ====================================================================
   CALENDAR
   ==================================================================== */
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 6px 0 14px;
  border-bottom: 1px solid var(--border);
}
.cal-nav {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 16px;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 12px 0;
}
.cal-weekday {
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 0;
}
.cal-day {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 72px;
  padding: 6px 8px;
  position: relative;
}
.cal-day.muted { opacity: 0.45; }
.cal-day.today {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 2px rgba(194,98,46,0.15);
}
.cal-num { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.cal-num-heb { font-size: 10px; color: var(--muted); margin-inline-start: 4px; }
.cal-events { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.cal-ev {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--terracotta-tint);
  color: var(--terracotta-2);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-ev.bd    { background: #ffe3cf; color: var(--terracotta-2); }
.cal-ev.anniv { background: #ede0f1; color: #7c5a8a; }
.cal-ev.yahr  { background: #e6e0d4; color: #6e5e3a; }
.cal-ev.bm    { background: #f5e8c8; color: #a78327; }
.cal-ev.ev    { background: #dcebe4; color: var(--sage); }

.calendar-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 10px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px dashed var(--border);
}
.event-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-inline-end: 4px;
  vertical-align: middle;
}
.event-dot.bd    { background: var(--terracotta); }
.event-dot.anniv { background: var(--plum); }
.event-dot.yahr  { background: #8c7b6e; }
.event-dot.bm    { background: var(--gold); }
.event-dot.ev    { background: var(--sage); }

/* ====================================================================
   EVENTS
   ==================================================================== */
.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.event-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.event-card .event-kind {
  display: inline-block;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  background: var(--terracotta-tint);
  color: var(--terracotta-2);
}
.event-card h3 {
  font-size: 17px;
  margin: 8px 0 4px;
}
.event-meta {
  color: var(--muted);
  font-size: 13px;
}
.event-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.event-stat {
  text-align: center;
}
.event-stat .num {
  display: block;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}
.event-stat .lbl {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

/* ====================================================================
   GUESTS / TABLE
   ==================================================================== */
.rsvp-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.rsvp-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.rsvp-card .num { font-size: 24px; font-weight: 800; }
.rsvp-card .lbl { color: var(--muted); font-size: 12.5px; }
.rsvp-card.ok   .num { color: var(--ok); }
.rsvp-card.warn .num { color: var(--warn); }
.rsvp-card.no   .num { color: var(--danger); }
.rsvp-card.q    .num { color: var(--info); }
.guest-category-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.guest-cat-chip {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: 130px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-2);
}
.guest-cat-chip span {
  color: var(--muted);
  font-size: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  text-align: start;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table th {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-2);
}
.table tr:hover td { background: var(--card-2); }
.rsvp-pill {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.rsvp-pill.confirmed { background: var(--ok-soft); color: var(--ok); }
.rsvp-pill.invited   { background: var(--info-soft); color: var(--info); }
.rsvp-pill.declined  { background: var(--danger-soft); color: var(--danger); }
.rsvp-pill.maybe     { background: var(--warn-soft); color: var(--warn); }
.rsvp-pill.no        { background: var(--bg-2); color: var(--muted); }

/* ====================================================================
   MAP PLACEHOLDER
   ==================================================================== */
.map-card { padding: 0; overflow: hidden; }
.map-placeholder { position: relative; }
.map-illustration { line-height: 0; }
.map-pin {
  cursor: pointer;
  filter: drop-shadow(0 2px 3px rgba(70,40,20,0.30));
}
.map-cities {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-start: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 240px;
}
.map-city {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}
.map-city .pin {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--terracotta);
}
.map-city b { color: var(--text); margin-inline-end: 4px; }
.map-card .muted.small {
  padding: 10px 16px;
  font-size: 12px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
}
.small { font-size: 12px; }
.muted { color: var(--muted); }

/* ====================================================================
   DRAFTS GRID
   ==================================================================== */
.drafts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}
.draft-card {
  background: var(--card);
  border: 1px dashed var(--terracotta-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.draft-card .draft-kind {
  display: inline-block;
  font-size: 11px;
  background: var(--terracotta-tint);
  color: var(--terracotta-2);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
}
.draft-card h3 { font-size: 15px; margin: 8px 0 6px; }
.draft-card .draft-body { color: var(--text-2); font-size: 13px; }
.draft-card .draft-meta { color: var(--muted); font-size: 12px; margin-top: 6px; }
.draft-card .draft-actions {
  display: flex; gap: 6px; margin-top: 12px;
  padding-top: 10px; border-top: 1px dashed var(--border);
}

/* ====================================================================
   LINKED TREES
   ==================================================================== */
.linked-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.linked-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.linked-card h3 { font-size: 15px; }
.linked-mode {
  display: inline-block;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #ecf3ef;
  color: var(--sage);
  font-weight: 700;
  margin-bottom: 6px;
}

/* ====================================================================
   REPORTS
   ==================================================================== */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.report-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  text-align: start;
}
.report-card .report-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 18px;
  background: var(--terracotta-tint);
  color: var(--terracotta-2);
  margin-bottom: 8px;
}
.report-card h3 { font-size: 14px; margin-bottom: 4px; }
.report-card p  { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.report-card button {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
}
.report-card button:hover { background: var(--bg-2); }

/* ====================================================================
   MODULES / SETTINGS
   ==================================================================== */
.modules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.module-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
}
.module-row .m-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.m-status.planned { background: var(--bg); color: var(--muted); }
.m-status.beta    { background: var(--warn-soft); color: var(--warn); }
.m-status.ready   { background: var(--ok-soft); color: var(--ok); }
.m-status.draft   { background: var(--info-soft); color: var(--info); }

.radio-list, .roles-list, .privacy-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0 0;
  font-size: 13px;
}
.radio-list label {
  display: flex; gap: 8px; align-items: center;
  color: var(--text-2);
}
.roles-list li, .privacy-list li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  color: var(--text-2);
}
.roles-list li:last-child, .privacy-list li:last-child { border-bottom: 0; }

/* ====================================================================
   TOAST
   ==================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ====================================================================
   RESPONSIVE
   ==================================================================== */
@media (max-width: 980px) {
  :root { --sidebar-w: 220px; }
  .topbar-center { display: none; }
}
@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-inline-start: 0;
    border-bottom: 1px solid var(--border);
  }
  .main { margin-inline-start: 0; }
  .nav { display: grid; grid-template-columns: repeat(2, 1fr); }
  .sidebar-footer { display: none; }
  .topbar { grid-template-columns: 1fr auto; gap: 8px; padding: 0 14px; }
  .quick-switch { display: none; }
  .content { padding: 16px; }
}
/* ====================================================================
   Family OS additions for modal/forms/state UI.
   Appended to the original warm RTL design system.
   ==================================================================== */

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 36, 22, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.modal-overlay.show { opacity: 1; }

.modal {
  background: var(--card, #fff);
  border-radius: 16px;
  width: min(560px, 92vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 28px 60px -16px rgba(45, 36, 22, 0.35);
  overflow: hidden;
  border: 1px solid var(--border, #efe2d3);
  transform: translateY(8px);
  transition: transform 0.22s cubic-bezier(.2,.7,.3,1.1);
}
.modal-overlay.show .modal { transform: translateY(0); }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border, #efe2d3);
  background: linear-gradient(180deg, var(--card-2, #fffaf4), transparent);
}
.modal-head h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--text-2, #4a3d2c);
}
.modal-close {
  background: transparent;
  border: 0;
  font-size: 28px;
  line-height: 1;
  color: var(--muted, #8c7b6e);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
}
.modal-close:hover { background: var(--bg-2, #faeee2); }

.modal-body {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 12px;
  margin-top: 4px;
  border-top: 1px solid var(--border, #efe2d3);
}

/* Form fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2, #4a3d2c);
}
.field-hint {
  font-size: 12px;
  color: var(--muted, #8c7b6e);
}
.field input, .field select, .field textarea {
  border: 1px solid var(--border-strong, #e3cfb8);
  background: var(--card-2, #fffaf4);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text, #2d2416);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--terracotta, #c2622e);
  box-shadow: 0 0 0 3px rgba(194, 98, 46, 0.16);
}
.field textarea { resize: vertical; min-height: 56px; }

/* RSVP inline select */
.rsvp-select {
  border-radius: 999px;
  border: 1px solid var(--border-strong, #e3cfb8);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #fff;
  cursor: pointer;
}
.rsvp-select.confirmed { background:#e6f2eb; color:#2f8a5d; border-color:#bce0cc; }
.rsvp-select.invited   { background:#f3ecf6; color:#7d5a93; border-color:#dfd0e7; }
.rsvp-select.maybe     { background:#fbf1da; color:#9b7424; border-color:#ecd9aa; }
.rsvp-select.declined  { background:#fde2dc; color:#a23a25; border-color:#f3c4b8; }

/* Draft state badge */
.draft-status {
  position: absolute;
  inset-block-start: 14px;
  inset-inline-start: 14px;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.draft-status.open      { background:#f3ecf6; color:#7d5a93; }
.draft-status.approved  { background:#e6f2eb; color:#2f8a5d; }
.draft-status.rejected  { background:#fde2dc; color:#a23a25; }
.draft-status.clarify   { background:#fbf1da; color:#9b7424; }
.draft-card { position: relative; }
.draft-card.approved { opacity: 0.85; }
.draft-card.rejected { opacity: 0.6; }

/* Event card actions row */
.event-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.event-actions .btn { padding: 6px 12px; font-size: 12px; }

.event-items-panel {
  display: grid;
  gap: 12px;
}
.event-items-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.event-items-head h2 { margin: 0; font-size: 18px; }
.event-item-group {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card-2);
  padding: 12px;
}
.event-item-group h3 {
  margin: 0 0 8px;
  font-size: 14px;
}
.event-item-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 2fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.event-item-row:first-of-type { border-top: 0; }

/* Toast variants */
.toast.err {
  background: #fde2dc;
  color: #a23a25;
  border: 1px solid #f3c4b8;
}

/* Small empty-state */
.muted { color: var(--muted, #8c7b6e); }

/* =============================================================
 * Tree details DRAWER + onboarding (revised 2026-05-19)
 * ============================================================= */
.panel-gender {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  font-size: 14px; background: #f4ebd8; color: #6a4d2c;
}
.panel-gender.small { width: 18px; height: 18px; font-size: 11px; }
.panel-gender.big   { width: 42px; height: 42px; font-size: 22px; }
.panel-gender.male    { background: #d9e6f3; color: #2563aa; }
.panel-gender.female  { background: #f5dbe9; color: #b14b8a; }
.panel-gender.unknown { background: #ece6dc; color: #8b7a5e; }
.small { font-size: 12px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger-ghost {
  background: transparent; border: 1px solid #e7c2b8;
  color: #a23a25; padding: 6px 12px; border-radius: 8px;
  font-size: 13px; cursor: pointer;
}
.btn-danger-ghost:hover { background: #fde2dc; }

.tree-node-rect.male   { fill: #f3f7fc; }
.tree-node-rect.female { fill: #fdf3f7; }
.tree-node-rect.selected { stroke-width: 3; filter: drop-shadow(0 0 4px rgba(194,98,46,0.45)); }
.tree-node-gender { font-family: system-ui, -apple-system, sans-serif; }

.tree-hint {
  display: flex; gap: 8px; align-items: center;
  background: #fdf6e6;
  border: 1px solid #ecd9bf;
  border-radius: 10px;
  padding: 8px 14px;
  margin-bottom: 12px;
  color: #6a4d2c;
  font-size: 13px;
}
.tree-hint-icon { font-size: 16px; }

.tree-empty {
  padding: 32px 20px;
  text-align: center;
  border: 1px dashed #e2d2b3;
  border-radius: 14px;
  background: #fffaf0;
}
.tree-empty h3 { margin: 0 0 8px; color: #6a4d2c; }
.tree-empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

/* ----- Person Drawer Overlay (centered, prominent) ----- */
.person-drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(50,30,10,0.45);
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 160ms ease;
  padding: 24px;
}
.person-drawer-overlay.show { opacity: 1; }
.person-drawer {
  background: #fffaf3;
  border-radius: 16px;
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(60,30,10,0.30);
  padding: 22px 24px 26px;
  direction: rtl;
  transform: translateY(8px);
  transition: transform 160ms ease;
}
.person-drawer-overlay.show .person-drawer { transform: translateY(0); }
.drawer-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid #efe2cc;
  padding-bottom: 14px;
}
.drawer-head-title { display: flex; gap: 12px; align-items: center; }
.drawer-head-title h2 { margin: 0; font-size: 22px; color: #4a3a25; }
.drawer-sub { font-size: 13px; margin-top: 2px; }
.drawer-head-actions { display: flex; gap: 8px; align-items: center; }
.drawer-close {
  background: transparent; border: 0; font-size: 26px;
  color: #8b7a5e; cursor: pointer; line-height: 1; padding: 0 8px;
}
.drawer-close:hover { color: #6a4d2c; }

.drawer-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin: 16px 0 6px;
  padding: 14px;
  background: #fff8ea;
  border: 1px solid #f1e1c4;
  border-radius: 12px;
}
.drawer-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #8b7a5e; }
.drawer-field-lbl { font-weight: 600; }
.drawer-field .qs {
  border: 1px solid #e2d2b3; border-radius: 8px;
  padding: 6px 10px; font-size: 13px; background: #fff; color: #4a3a25;
  font-family: inherit;
}
.drawer-field .qs:focus { outline: 2px solid #c2622e; outline-offset: -2px; }

.drawer-graph {
  margin-top: 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.drawer-row {
  background: #fff;
  border: 1px solid #efe2cc;
  border-radius: 12px;
  padding: 12px 14px;
}
.drawer-row-label {
  font-size: 12px;
  font-weight: 700;
  color: #c2622e;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.drawer-row-cards {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: stretch;
}
.drawer-row-self  { background: #fef4e1; border-color: #e8c898; }
.drawer-row-parents .drawer-row-label::before { content: '⬆️ '; }
.drawer-row-children .drawer-row-label::before { content: '⬇️ '; }
.drawer-row-self .drawer-row-label::before { content: '❤️ '; }

.fcard {
  display: flex; gap: 10px; align-items: center;
  min-width: 180px;
  background: #fff;
  border: 1px solid #ecd9bf;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: right;
  cursor: pointer;
  transition: all 120ms ease;
  font-family: inherit;
  color: #4a3a25;
}
.fcard:hover { border-color: #c2622e; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(120,80,30,0.08); }
.fcard-body { display: flex; flex-direction: column; gap: 2px; }
.fcard-role { font-size: 11px; color: #8b7a5e; font-weight: 600; letter-spacing: 0.03em; }
.fcard-name { font-size: 14px; color: #4a3a25; }
.fcard-meta { font-size: 11px; }
.fcard-self {
  background: linear-gradient(135deg, #fff5e0, #fef0d2);
  border: 2px solid #c2622e;
  cursor: default;
}
.fcard-self:hover { transform: none; box-shadow: none; }
.fcard-add {
  background: transparent;
  border: 2px dashed #d8c8a6;
  color: #8b7a5e;
}
.fcard-add:hover { border-color: #c2622e; background: #fff8ea; color: #6a4d2c; }
.fcard-add.male:hover   { border-color: #2563aa; }
.fcard-add.female:hover { border-color: #b14b8a; }
.fcard-plus {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: #f4ebd8; color: #6a4d2c; font-weight: 700;
}

@media (max-width: 720px) {
  .person-drawer { padding: 16px; }
  .drawer-head-title h2 { font-size: 18px; }
  .drawer-fields { grid-template-columns: 1fr 1fr; }
  .fcard { min-width: 140px; flex: 1; }
}


/* Final layering fixes (v2): generic modal must always sit ABOVE the person drawer.
   Previously the drawer was forced on top — that caused modals opened from the drawer
   to be visually hidden behind it. The drawer is also synchronously closed before any
   modal opens, but in case both are present the modal must win. */
.person-drawer-overlay { z-index: 9000 !important; }
.person-drawer { z-index: 9001 !important; position: relative; }
.modal-overlay { z-index: 30000 !important; }
.modal { z-index: 30001 !important; position: relative; }
.field-hint.mono { display:block; margin-top:4px; color:#9a6a37; font-size:12px; }

/* Quick-family entry form */
.qf-section { margin: 14px 0 10px; padding: 12px 14px; background: #fdf7ef; border: 1px solid #efe2d3; border-radius: 12px; }
.qf-section h3 { margin: 0 0 10px; font-size: 15px; color: #6b4a22; }
.qf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qf-grid.qf-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.qf-children-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.qf-child-row { display: grid; grid-template-columns: 1.4fr 0.9fr 1.1fr auto; gap: 8px; align-items: end; padding: 8px; background: #fffaf2; border: 1px dashed #e6d3b6; border-radius: 10px; }
.qf-child-row .field { margin: 0; }
.qf-child-row .qf-heb { font-size: 11px; color: #8b6a37; }
.qf-remove-child { background: transparent; border: 1px solid #e2b3a3; color: #a94a32; border-radius: 8px; padding: 4px 8px; cursor: pointer; align-self: center; }
.qf-remove-child:hover { background: #fff1ec; }
.qf-add-child { margin-top: 6px; background: #fff; border: 1px dashed #c9a36c; color: #8b5a1e; border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 600; }
.qf-add-child:hover { background: #fff5e3; }
.qf-help { color: #8b7a5e; font-size: 12px; margin: 4px 0 8px; }
.btn-quick-family { background: linear-gradient(180deg,#f4c478,#c2622e); color:#fff; border: 1px solid #a85016; }
.btn-quick-family:hover { filter: brightness(1.06); }

/* Person picker for relationship choose-or-create */
.pp-block { margin: 6px 0 10px; padding: 8px; background: #fff; border: 1px solid #efe2d3; border-radius: 10px; }
.pp-label { font-weight: 600; color: #6b4a22; font-size: 13px; margin-bottom: 4px; }
.pp-help { font-size: 11px; color: #8b7a5e; margin-bottom: 6px; }
.pp-block input[type="search"] { width: 100%; padding: 6px 10px; border: 1px solid #d8c5a8; border-radius: 8px; font-size: 13px; }
.pp-drop { margin-top: 4px; max-height: 200px; overflow-y: auto; background: #fffaf2; border: 1px solid #e6d3b6; border-radius: 8px; }
.pp-drop[hidden] { display: none; }
.pp-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; width: 100%; align-items: center; padding: 6px 10px; background: transparent; border: 0; border-bottom: 1px solid #f1e3c9; cursor: pointer; text-align: right; font-size: 13px; }
.pp-row:hover { background: #fff1d6; }
.pp-row:last-child { border-bottom: 0; }
.pp-row-name { font-weight: 600; color: #5b3f1a; }
.pp-row-meta { font-size: 11px; }
.pp-empty { padding: 8px 10px; font-size: 12px; }
.pp-selected { margin-top: 4px; }
.pp-selected[hidden] { display: none; }
.pp-tag { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; background: linear-gradient(180deg,#fff5d8,#f8e0a8); border: 1px solid #c9a36c; border-radius: 999px; font-size: 13px; color: #5b3f1a; }
.pp-tag-icon { font-weight: 700; }
.pp-tag-meta { font-size: 11px; }
.pp-clear { margin-right: 4px; background: transparent; border: 0; color: #a94a32; cursor: pointer; font-size: 11px; }
.pp-clear:hover { text-decoration: underline; }

/* Engagement + wedding dates per SPOUSE relationship */
.spouse-dates { margin: 8px 0 4px; padding: 10px 14px; background: linear-gradient(180deg,#fff9eb,#fdf2dc); border: 1px solid #e8c98c; border-radius: 12px; }
.spouse-dates-title { font-weight: 700; color: #6b4a22; margin-bottom: 6px; font-size: 14px; }
.spouse-dates-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 720px) { .spouse-dates-grid { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .qf-grid, .qf-grid.qf-grid-3 { grid-template-columns: 1fr; }
  .qf-child-row { grid-template-columns: 1fr 1fr; }
  .qf-child-row .qf-remove-child { grid-column: span 2; justify-self: end; }
}

/* Quick-family multi-couple layout */
.qf-help-banner { margin: 6px 0 14px; padding: 10px 14px; background: linear-gradient(180deg,#fff8e6,#fdeac8); border: 1px solid #e6c98a; border-radius: 12px; }
.qf-help-title { font-weight: 700; color: #6b4a22; font-size: 14px; margin-bottom: 4px; }
.qf-couples-list { display: flex; flex-direction: column; gap: 16px; }
.qf-couple-card { padding: 12px 14px; background: #fdf7ef; border: 2px solid #d8b87a; border-radius: 14px; box-shadow: 0 2px 6px rgba(170, 120, 50, 0.08); }
.qf-couple-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px dashed #e6d3b6; }
.qf-couple-title { margin: 0; font-size: 16px; color: #6b4a22; font-weight: 700; }
.qf-couple-hint { font-size: 12px; }
.qf-couple-remove { background: transparent; border: 1px solid #e2b3a3; color: #a94a32; border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.qf-couple-remove:hover { background: #fff1ec; }
.qf-couple-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; }
.qf-person { padding: 10px 12px; background: #fff; border: 1px solid #efe2d3; border-radius: 10px; }
.qf-person-title { margin: 0 0 8px; font-size: 14px; color: #6b4a22; font-weight: 700; }
.qf-couple-dates { margin: 12px 0 4px; padding: 10px 14px; background: linear-gradient(180deg,#fff9eb,#fdf2dc); border: 1px solid #e8c98c; border-radius: 12px; }
.qf-couple-dates-title { font-weight: 700; color: #6b4a22; margin-bottom: 6px; font-size: 13px; }
.qf-couple-children { margin-top: 12px; padding: 10px 14px; background: #fffaf2; border: 1px dashed #e6d3b6; border-radius: 12px; }
.qf-couple-children-title { font-weight: 700; color: #6b4a22; margin-bottom: 6px; font-size: 13px; }
.qf-add-couple { margin-top: 14px; background: linear-gradient(180deg,#fff,#fdebc8); border: 2px dashed #c9a36c; color: #8b5a1e; border-radius: 12px; padding: 10px 14px; cursor: pointer; font-weight: 700; width: 100%; }
.qf-add-couple:hover { background: linear-gradient(180deg,#fff5e3,#fbdfa6); }
@media (max-width: 720px) {
  .qf-couple-pair { grid-template-columns: 1fr; }
  .qf-couple-head { grid-template-columns: 1fr auto; }
  .qf-couple-hint { grid-column: 1 / -1; }
}

/* ====================================================================
   Tree viewer toolbar + pan/zoom (upgrade)
   ==================================================================== */
.tree-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 12px;
  background: #fffaf3;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.02);
}
.tt-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.tt-btn {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
}
.tt-btn:hover { background: var(--bg-2); }
.tt-btn:active { transform: translateY(1px); }
.tt-zoom-level {
  min-width: 46px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tt-label { font-size: 12.5px; color: var(--muted); padding: 0 6px; }
.tt-seg { display: inline-flex; gap: 2px; }
.tt-seg-btn {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  border-radius: 6px;
  cursor: pointer;
  min-width: 30px;
}
.tt-seg-btn:hover { background: var(--bg-2); }
.tt-seg-btn.is-active {
  background: var(--terracotta, #c2622e);
  color: #fff;
}

/* Mode segment is the same widget; it just gets a touch more breathing room
   so the Hebrew labels don't clash with the generation digits beside it. */
.tt-mode .tt-seg-btn { padding: 6px 12px; }
.tt-mode .tt-seg-btn.is-active {
  background: var(--olive, #5b8b78);
}

/* Mode banner under the SVG — explains which subset is shown and offers a
   one-click escape hatch back to the full family view. */
.tree-mode-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 8px 4px 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-2, #f6efe2);
  color: var(--text-2, #5a4f3b);
  font-size: 12.5px;
  border: 1px solid var(--border, #e3d6bd);
}
.tree-mode-note .tmn-text { font-weight: 600; }
.tree-mode-note .tmn-link {
  appearance: none;
  background: transparent;
  border: 1px solid var(--olive, #5b8b78);
  color: var(--olive, #5b8b78);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.tree-mode-note .tmn-link:hover { background: var(--olive, #5b8b78); color: #fff; }
.tree-mode-note .tmn-warn { color: #b14b3a; font-weight: 600; }
.tt-spacer { flex: 1; }
.tt-hint {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* Pan/zoom viewport (the wrap becomes a scrolling viewport; stage is the
   scaled inner that contains the SVG). */
.tree-svg-wrap {
  position: relative;
  width: 100%;
  height: clamp(480px, 70vh, 820px);
  overflow: auto;
  background:
    radial-gradient(circle at 1px 1px, rgba(140,123,110,0.18) 1px, transparent 0) 0 0 / 22px 22px,
    linear-gradient(180deg, #fffaf4, #fdf6f0);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: grab;
  user-select: none;
}
.tree-svg-wrap.is-panning { cursor: grabbing; }
.tree-stage {
  transform-origin: 0 0;
  transition: transform 120ms ease-out;
  padding: 24px;
  display: inline-block;
  min-width: 100%;
}
.tree-svg-wrap.no-anim .tree-stage { transition: none; }
.tree-svg-wrap svg {
  display: block;
  margin: 0 auto;
  /* allow SVG to be intrinsic-sized so we can fit/zoom it accurately */
  max-width: none;
}

/* Add placeholders rendered above parents and below children */
.tree-add-placeholder {
  fill: #fff;
  stroke: #c8b48a;
  stroke-dasharray: 4 4;
  cursor: pointer;
  opacity: 0.85;
}
.tree-add-placeholder:hover { opacity: 1; fill: #fff5e6; }
.tree-add-label {
  font-size: 11px;
  font-weight: 700;
  fill: #8a6a3a;
  pointer-events: none;
}

/* Expand/collapse chevrons sitting above and below each tree unit.
   Tiny circular pill so it cannot be confused with the person card. */
.tree-chev {
  transition: transform 120ms ease, filter 120ms ease;
}
.tree-chev:hover { filter: drop-shadow(0 1px 3px rgba(60,40,20,0.25)); }
.tree-chev:hover .tree-chev-bg { fill: #fff5e6; stroke: #c2622e; }
.tree-chev-bg {
  fill: #ffffff;
  stroke: #b08b58;
  stroke-width: 1.2;
}
.tree-chev.is-collapsed .tree-chev-bg {
  fill: #fff1d6;
  stroke: #c2622e;
  stroke-dasharray: 3 2;
}
.tree-chev-glyph {
  font-size: 13px;
  font-weight: 800;
  fill: #6a4a20;
  pointer-events: none;
  font-family: system-ui, -apple-system, sans-serif;
}
.tree-chev-arrow {
  font-size: 7px;
  fill: #8a6a3a;
  pointer-events: none;
}
.tree-chev.is-collapsed .tree-chev-glyph { fill: #c2622e; }
.tree-chev-badge-bg {
  fill: #c2622e;
  stroke: #fff;
  stroke-width: 1;
}
.tree-chev-badge {
  fill: #fff;
  font-size: 9px;
  font-weight: 700;
  pointer-events: none;
}

/* Dotted placeholder shown in place of hidden ancestors/descendants. */
.tree-hidden-ph { transition: opacity 120ms ease; }
.tree-hidden-ph:hover .tree-hidden-rect { fill: #fff5e6; }
.tree-hidden-rect {
  fill: #fcf6e7;
  stroke: #c8b48a;
  stroke-dasharray: 3 3;
  stroke-width: 1.2;
}
.tree-hidden-label {
  font-size: 10px;
  font-weight: 700;
  fill: #8a6a3a;
  pointer-events: none;
}

/* Subtle empty-state for filtered generations */
.tree-filter-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  background: #fff8ec;
  border: 1px dashed #d8c8a4;
  border-radius: 999px;
  padding: 3px 10px;
}

.tile-family-surname {
  color: #a35f24;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 3px;
}

/* Launch readiness + duplicate review */
.launch-check-grid,
.duplicate-review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.launch-check {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
}
.launch-check.ok { border-color: #b9dec8; background: #f1fbf5; }
.launch-check.warn { border-color: #f0c9a5; background: #fff7ed; }
.launch-check p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.lc-icon {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: #fff;
  color: var(--sage);
}
.launch-check.warn .lc-icon { color: var(--warn); }
.duplicate-group {
  padding: 10px 12px;
  border: 1px solid #eed7bd;
  background: #fff8ef;
  border-radius: 12px;
}
.duplicate-group h3 { margin: 0 0 8px; font-size: 14px; color: #7a4f22; }
.duplicate-person {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 2fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid #f0e1cc;
}
.duplicate-person:first-of-type { border-top: 0; }
