/* Upgraded Ilonca Interactive Tree Styles — Full-Box Family Color Fills */
.tree-page-main { padding-top: 20px; padding-bottom: 48px; }

.tree-legend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.tree-legend-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tree-legend-top h2 {
  font-family: var(--serif);
  font-size: 20px;
  margin: 0;
}
.tree-legend-top p {
  margin: 2px 0 0;
  font-size: 13.5px;
  color: var(--ink-muted);
}

.palette-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.pal-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1.5px solid var(--chip-border, #8D8474);
  background: var(--chip-fill, #F7F3EA);
  color: #162230;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.14s ease;
}
.pal-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(27, 40, 56, 0.14);
}
.pal-chip.active {
  box-shadow: 0 0 0 2.5px var(--ink);
}
.pal-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--chip-border, #8D8474);
  flex-shrink: 0;
}
.pal-cnt { font-weight: 500; opacity: 0.78; font-variant-numeric: tabular-nums; }

.branches-drawer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.branches-drawer summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--forest);
  user-select: none;
}
.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.branch-jump {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1.5px solid var(--branch, #8D8474);
  border-left-width: 5px;
  background: var(--branch-fill, #F7F3EA);
  color: #162230;
  text-align: left;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.14s ease;
}
.branch-jump:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.branch-jump[aria-current="true"] { box-shadow: 0 0 0 2.5px var(--ink); }
.branch-family { font-size: 13px; font-weight: 700; }
.branch-detail { font-size: 12px; color: #364556; }

/* Search & Start Console */
.tree-console {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.tree-console label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 5px;
}
.tree-console input,
.tree-console select {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: 8px;
  background: #FFF;
  color: var(--ink);
  font-size: 14.5px;
  font-family: var(--sans);
}
.finder { position: relative; min-width: 0; }
.results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 25;
  background: #FFF;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  max-height: 42vh;
  overflow: auto;
  padding: 5px;
  box-shadow: var(--shadow-lg);
}
.results p { margin: 0; padding: 10px; font-size: 14px; color: var(--ink-muted); }
.result {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}
.result:hover { background: var(--gold-soft); }
.result small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-muted); }

/* Tree Stage */
.tree-stage {
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow-sm);
}
.linebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.linebar-title-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.linebar h2 {
  font-family: var(--serif);
  font-size: 24px;
  margin: 0;
  line-height: 1.2;
}
.tree-counts-pill {
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--ink-soft);
}
.tree-line-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12.5px;
  color: var(--ink-soft);
  align-items: center;
}
.tree-line-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.line-solid { display: inline-block; width: 20px; border-top: 2px solid #2A4352; }
.line-dashed { display: inline-block; width: 20px; border-top: 2px dashed #9A6424; }
.line-double { display: inline-block; width: 20px; height: 5px; border-top: 1.6px solid #2A4352; border-bottom: 1.6px solid #2A4352; }
.grave-key-pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--ink);
  color: #F6E6C2;
}

.tree-toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 12px 0 8px;
}
.toolbar-spacer { flex: 1 1 auto; }
.gen-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.gen-label select {
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #FFF;
  color: var(--ink);
  font-size: 13px;
}

.via-note {
  margin: 4px 0 6px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--gold-soft);
  color: #543D14;
  font-size: 13.5px;
  font-weight: 500;
}
.trail-note {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--ink-muted);
}

/* Interactive Chart Viewport & Board */
.chart-view {
  position: relative;
  width: 100%;
  min-height: 640px;
  height: calc(100vh - 220px);
  max-height: 980px;
  overflow: auto;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  background:
    radial-gradient(circle at 20px 20px, rgba(154,116,50,0.06) 1px, transparent 1px) 0 0 / 24px 24px,
    #F3EFE5;
  cursor: grab;
}
.chart-view:active { cursor: grabbing; }
.chart-size { position: relative; }
.chart-board { position: relative; transform-origin: top left; }

.diagram-lines { position: absolute; inset: 0; pointer-events: none; }
.diagram-lines path { fill: none; }
.diagram-lines .transmission {
  stroke: #2A4352;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.diagram-lines .transmission.likely {
  stroke: #2A4352;
  stroke-dasharray: none;
}
.diagram-lines .transmission.possible {
  stroke: #9A6424;
  stroke-dasharray: 5 4;
}
.diagram-lines .marriage {
  stroke: #2A4352;
  stroke-width: 1.65;
}
.diagram-lines .marriage.possible {
  stroke: #9A6424;
  stroke-dasharray: 4 3;
}
.diagram-lines .grid-line {
  stroke: #B8AE9B;
  stroke-width: 1;
  stroke-dasharray: 2 4;
  opacity: 0.55;
}

.graph-annotation {
  position: absolute;
  width: 108px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #4D5966;
  background: rgba(243, 239, 229, 0.9);
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1.25;
  pointer-events: none;
}

.children-frame {
  position: absolute;
  border: 1px dashed rgba(114, 102, 82, 0.45);
  border-radius: 12px;
  background: rgba(255, 252, 244, 0.48);
  pointer-events: none;
}
.children-frame .children-caption {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: calc(var(--family-gutter) - 18px);
  max-height: calc(100% - 20px);
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #FCF9F3;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

/* FULL-BOX FAMILY COLOR-FILLED CARDS */
.graph-card {
  position: absolute;
  width: 218px;
  height: 188px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  --branch: #7B7060;
  --box-fill: #F7F3EA;
  --box-accent: #443B2E;
  background: var(--box-fill);
  border: 1.8px solid var(--branch);
  border-left: 5px solid var(--branch);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(27, 40, 56, 0.11);
  transition: box-shadow 0.14s ease, transform 0.12s ease, opacity 0.15s ease;
}
.graph-card:hover {
  box-shadow: 0 7px 18px rgba(27, 40, 56, 0.18);
  z-index: 6;
}
.graph-card.key {
  box-shadow: 0 0 0 2.5px var(--ink), 0 6px 16px rgba(27, 40, 56, 0.2);
}
.graph-card.open {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.graph-card.family-dim { opacity: 0.84; filter: saturate(0.72); }
.graph-card.family-hi {
  box-shadow: 0 0 0 3px var(--branch), 0 8px 20px rgba(27, 40, 56, 0.22);
  z-index: 5;
}

.graph-main {
  border: 0;
  background: transparent;
  align-self: stretch;
  padding: 9px 6px 7px 10px;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 3px;
  min-width: 0;
  min-height: 0;
  color: #15212E;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.graph-main:hover { background: rgba(255, 255, 255, 0.34); }
.name-text {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.14;
  color: #13202D;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 0 0 auto;
}
.graph-meta {
  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--box-accent);
  font-variant-numeric: tabular-nums;
}
.card-grave-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 1px;
}
.card-grave-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--ink);
  color: #F6E6C2;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.card-facts {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.18;
  color: #243445;
}
.card-fact, .card-bio {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  flex-shrink: 0;
}
.card-bio { font-weight: 600; color: #1E3242; }
.graph-evidence {
  font-size: 10px;
  font-weight: 700;
  color: #7D4E13;
  background: rgba(255, 248, 232, 0.85);
  border: 1px solid #C89B5B;
  border-radius: 4px;
  padding: 1px 5px;
  width: fit-content;
}
.graph-action {
  margin-top: auto;
  padding-top: 2px;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--box-accent);
  flex: 0 0 auto;
}

.source-dot {
  align-self: start;
  margin: 5px 5px 0 0;
  border: 1px solid rgba(27, 40, 56, 0.2);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  padding: 0;
  background: rgba(255, 255, 255, 0.72);
  color: var(--box-accent);
  font-size: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.source-dot:hover { background: #FFF; border-color: var(--ink); }

/* Branch Expand/Fold Arrows */
.branch-arrow {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.branch-arrow::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1.5px solid #6E7B88;
  background: #FCF9F3;
  box-shadow: 0 2px 4px rgba(27, 40, 56, 0.16);
}
.branch-arrow[aria-expanded="true"]::before {
  background: var(--gold-soft);
  border-color: var(--gold-dark);
}
.branch-arrow:hover::before {
  background: #EFE3CA;
  border-color: var(--ink);
}
.branch-chevron {
  position: relative;
  display: block;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}
.branch-chevron.points-up { transform: translateY(2px) rotate(225deg); }
.branch-arrow-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.branch-jump-existing::before { border-style: dotted; background: #EFE9DC; }

/* Profile Source Dialog */
.source-dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: 86vh;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  box-shadow: var(--shadow-lg);
}
.source-dialog::backdrop { background: rgba(20, 30, 42, 0.56); }
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: var(--ink);
  color: #FCF9F3;
  border-bottom: 3px solid var(--gold);
}
.dialog-head h2 {
  font-family: var(--serif);
  font-size: 21px;
  margin: 0;
}
.dialog-head .btn-outline {
  background: rgba(255, 255, 255, 0.12);
  color: #FCF9F3;
  border-color: rgba(255, 255, 255, 0.35);
}
.dialog-body {
  padding: 18px 20px 22px;
  overflow: auto;
  max-height: calc(86vh - 68px);
}
.refcaption { margin: 0 0 12px; font-weight: 600; color: var(--ink-soft); }
.source-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.source { margin: 14px 0; }
.source h3 { font-family: var(--serif); font-size: 16.5px; margin: 0 0 8px; color: var(--ink); }
.source ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.source li {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #FFF;
  font-size: 14px;
}
.jump {
  border: 0;
  background: none;
  padding: 0;
  font-weight: 700;
  color: var(--forest);
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  margin-right: 8px;
}
.jump:hover { text-decoration: underline; }
.grade-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--forest-soft);
  color: var(--forest);
}
.grade-pill.possible { background: #F6E9D2; color: #7C4D12; }
.quiet { font-size: 12.5px; color: var(--ink-muted); margin-top: 3px; }
.name-variants ul { display: flex; flex-wrap: wrap; gap: 6px; }
.name-variants li { padding: 3px 8px; background: var(--surface-alt); font-size: 13px; }

@media (max-width: 760px) {
  .tree-console { grid-template-columns: 1fr; }
  .tree-stage { padding: 12px; }
  .chart-view { height: 540px; }
  .toolbar-spacer { display: none; }
}


/* WWII Memorial badge on Family Tree cards */
.card-wwii-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: #EAEFF4;
  color: #354759;
  border: 1px solid #C5D1DD;
}
.card-wwii-badge.wwii-perished {
  background: #F6E2E2;
  color: #822424;
  border-color: #DCAAAA;
}
.card-wwii-badge.wwii-survived {
  background: #DFF0E7;
  color: #1D5C3E;
  border-color: #A9D4BD;
}
.wwii-key-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.72rem;
  background: #F6E2E2;
  color: #822424;
  border: 1px solid #DCAAAA;
}

/* Wide-screen interactive canvas expansion & fullscreen mode */
.tree-legend-card { padding: 14px 18px; margin-bottom: 12px; }
.tree-console { padding: 12px 16px; margin-bottom: 12px; }
.tree-stage { padding: 14px 16px; }
.tree-stage.is-expanded,
.tree-stage:fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  border-radius: 0;
  border: 0;
  background: #FAF6ED;
  display: flex;
  flex-direction: column;
  padding: 12px 18px 14px;
}
.tree-stage.is-expanded .chart-view,
.tree-stage:fullscreen .chart-view {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  max-height: none;
}
body.tree-canvas-expanded { overflow: hidden; }
@media (max-width: 760px) {
  .chart-view { min-height: 460px; height: 64vh; }
}
