/* ============================================
   ШЕЖІРЕ v2 — ПОЛНЫЙ СТИЛЬ
   Дерево · Карточки · Деревянная тема · 3D
   ============================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Nunito', sans-serif;
  background: #0f0804;
  color: #f0d9a0;
  user-select: none;
}

/* ===================== HEADER ===================== */
#header {
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px; z-index: 100;
  background: linear-gradient(180deg, #1e1208 0%, #180e06 100%);
  border-bottom: 1px solid rgba(200,148,30,0.4);
  box-shadow: 0 2px 20px rgba(0,0,0,0.5);
  display: flex; align-items: center;
  padding: 0 20px; gap: 16px;
}
#header::after {
  content: '';
  position: absolute; bottom: -3px; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, #c8941e 20%, #e8b840 50%, #c8941e 80%, transparent);
  opacity: 0.5;
}

.header-logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo-circle {
  width: 36px; height: 36px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e8b840, #8a6010);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  box-shadow: 0 0 14px rgba(200,148,30,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
  animation: logoGlow 4s ease-in-out infinite;
}
@keyframes logoGlow {
  0%,100% { box-shadow: 0 0 14px rgba(200,148,30,0.4); }
  50%      { box-shadow: 0 0 26px rgba(200,148,30,0.7); }
}
.logo-title {
  font-family: 'Cinzel', serif; font-size: 17px; font-weight: 700;
  color: #e8d090; letter-spacing: 0.1em;
  text-shadow: 0 0 20px rgba(200,148,30,0.3);
}
.logo-sub { font-size: 10px; color: #6a4820; letter-spacing: 0.08em; }

.header-search { flex: 1; position: relative; max-width: 280px; }
.header-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #7a5830; pointer-events: none; }
#search-input {
  width: 100%; padding: 7px 12px 7px 30px;
  background: rgba(10,6,2,0.7); border: 1px solid rgba(160,100,20,0.35);
  border-radius: 20px; font-family: 'Nunito', sans-serif; font-size: 13px;
  color: #f0d9a0; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#search-input::placeholder { color: #4a3018; }
#search-input:focus { border-color: rgba(200,148,30,0.6); box-shadow: 0 0 0 3px rgba(200,148,30,0.1); }

#search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #1e1208; border: 1px solid rgba(200,148,30,0.4);
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6); display: none; z-index: 200;
}
#search-results.visible { display: block; }
.sr-item { padding: 9px 14px; cursor: pointer; border-bottom: 1px solid rgba(200,148,30,0.1); transition: background 0.15s; }
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: rgba(200,148,30,0.1); }
.sr-name { font-weight: 700; font-size: 13px; color: #f0d9a0; }
.sr-sub  { font-size: 11px; color: #7a5830; margin-top: 2px; }
.sr-tag  { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 8px; background: rgba(200,148,30,0.15); color: #c8941e; margin-left: 5px; }

.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.branch-switch { display: flex; background: rgba(10,6,2,0.6); border: 1px solid rgba(160,100,20,0.3); border-radius: 20px; padding: 3px; }
.branch-btn {
  padding: 4px 12px; border: none; border-radius: 14px; cursor: pointer;
  font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 600;
  color: #7a5830; background: none; transition: all 0.2s;
}
.branch-btn.active { background: linear-gradient(135deg, #c8941e, #8a6010); color: #1a0e04; box-shadow: 0 2px 8px rgba(200,148,30,0.3); }

.hdr-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px; border: 1px solid rgba(160,100,20,0.4);
  border-radius: 8px; background: rgba(10,6,2,0.5);
  color: #c8a870; cursor: pointer;
  font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 600;
  transition: all 0.15s;
}
.hdr-btn:hover { border-color: #c8941e; color: #e8b840; background: rgba(200,148,30,0.1); }

.user-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border: 1px solid rgba(160,100,20,0.3);
  border-radius: 20px; background: rgba(10,6,2,0.4);
  font-size: 12px; color: #c8a870;
}
.user-chip span { font-weight: 700; color: #e8b840; }
#btn-logout { background: none; border: none; cursor: pointer; color: #6a4820; font-size: 11px; font-family: 'Nunito', sans-serif; transition: color 0.15s; }
#btn-logout:hover { color: #c06060; }

/* ===================== SCENE ===================== */
#scene {
  position: fixed; inset: 56px 0 0 0;
  overflow: hidden; cursor: grab;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(40,20,5,0.8) 0%, transparent 70%),
    linear-gradient(180deg, #0a0502 0%, #120804 40%, #0f0703 100%);
}
#scene:active { cursor: grabbing; }

/* Wood grain on scene */
#scene::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(
    91deg,
    transparent 0px, transparent 30px,
    rgba(255,255,255,0.008) 30px, rgba(255,255,255,0.008) 31px
  );
}

/* Ground glow */
#scene::after {
  content: '';
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 600px; height: 200px;
  background: radial-gradient(ellipse, rgba(100,50,10,0.3) 0%, transparent 70%);
  pointer-events: none;
}

#branch-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 1;
}

#tree-wrap {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  transform-origin: 0 0;
  z-index: 2;
  overflow: visible;
}

/* ===================== TREE ROOT / TRUNK ===================== */
#tree-root {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
}

/* ===================== GENERATION ROWS ===================== */
.gen-row {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
}

/* ===================== NODE CARDS ===================== */
.node-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer;
  animation: cardAppear 0.5s cubic-bezier(.22,.68,0,1.2) both;
  transition: transform 0.25s cubic-bezier(.22,.68,0,1.2);
}
.node-card:hover { transform: scale(1.08) translateY(-4px); z-index: 10; }
.node-card:hover .card-glow { opacity: 1; }

@keyframes cardAppear {
  from { opacity: 0; transform: scale(0.7) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Avatar circle */
.card-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #3a2010, #1e1008);
  border: 2px solid rgba(200,148,30,0.5);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 6px; position: relative;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
  flex-shrink: 0;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.node-card:hover .card-avatar { border-color: rgba(200,148,30,0.9); box-shadow: 0 6px 24px rgba(200,148,30,0.25); }

.card-avatar svg { color: #7a5830; width: 28px; height: 28px; }

/* Level 0 (Сіз) — larger */
.node-level-0 .card-avatar {
  width: 70px; height: 70px;
  border: 2.5px solid rgba(232,184,64,0.8);
  background: linear-gradient(135deg, #4a2810, #2a1508);
  box-shadow: 0 0 24px rgba(200,148,30,0.35), 0 6px 20px rgba(0,0,0,0.5);
}
.node-level-0 .card-avatar svg { color: #c8941e; width: 36px; height: 36px; }

/* Wooden plaque */
.card-plaque {
  background: linear-gradient(160deg, #3a2010 0%, #2a1608 50%, #321a0c 100%);
  border: 1px solid rgba(200,148,30,0.45);
  border-radius: 8px;
  padding: 6px 12px;
  text-align: center; min-width: 90px; max-width: 120px;
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
}
.card-plaque::before {
  content: '';
  position: absolute; top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200,148,30,0.4), transparent);
}

.card-name {
  font-family: 'Cinzel', serif; font-size: 11px; font-weight: 600;
  color: #e8d090; letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.node-level-0 .card-name { font-size: 13px; color: #f0e0a0; }

.card-years {
  font-size: 10px; color: #8a6030; margin-top: 1px;
  font-weight: 500;
}
.card-ru {
  font-size: 9px; color: #6a4820; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Level badge */
.card-badge {
  position: absolute; top: -6px; right: -6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, #c8941e, #8a6010);
  border: 1px solid rgba(232,184,64,0.5);
  font-size: 9px; font-weight: 800; color: #1a0e04;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.node-level-0 .card-badge { display: none; }

/* Glow halo */
.card-glow {
  position: absolute; inset: -12px;
  border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(200,148,30,0.15) 0%, transparent 70%);
  transition: opacity 0.3s;
}

/* ===================== BRANCH LINES (SVG) ===================== */
.branch-line {
  fill: none;
  stroke: url(#branchGrad);
  stroke-width: 1.5;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* ===================== TREE TRUNK ===================== */
.trunk {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  width: 8px;
  background: linear-gradient(180deg, #8a5010 0%, #5a3008 100%);
  border-radius: 4px;
  box-shadow: 2px 0 8px rgba(0,0,0,0.4), -1px 0 4px rgba(200,148,30,0.1);
  transform-origin: bottom center;
  animation: trunkSway 6s ease-in-out infinite;
}
@keyframes trunkSway {
  0%,100% { transform: translateX(-50%) rotate(0deg); }
  50%      { transform: translateX(-50%) rotate(0.3deg); }
}

/* ===================== ANIMATED LEAVES ===================== */
.leaf {
  position: absolute;
  width: 10px; height: 14px;
  background: linear-gradient(135deg, #2a5010, #1a3008);
  border-radius: 50% 0 50% 0;
  opacity: 0.6;
  animation: leafSway 3s ease-in-out infinite;
}
@keyframes leafSway {
  0%,100% { transform: rotate(0deg) scale(1); }
  33%      { transform: rotate(8deg) scale(1.05); }
  66%      { transform: rotate(-5deg) scale(0.98); }
}

/* Floating particles */
.particle {
  position: absolute; border-radius: 50%;
  background: rgba(200,148,30,0.4);
  pointer-events: none;
  animation: particleFloat linear infinite;
}
@keyframes particleFloat {
  0%   { transform: translateY(0) translateX(0) scale(1); opacity: 0.6; }
  100% { transform: translateY(-200px) translateX(var(--dx, 20px)) scale(0); opacity: 0; }
}

/* ===================== EDIT PANEL ===================== */
.panel {
  position: fixed; right: 20px; top: 72px;
  width: 280px;
  background: linear-gradient(160deg, #2a1608, #1e1006);
  border: 1px solid rgba(200,148,30,0.45);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6), 0 0 0 1px rgba(200,148,30,0.1);
  z-index: 50; overflow: hidden;
  transition: opacity 0.25s, transform 0.25s;
}
.panel::before {
  content: ''; display: block; height: 2px;
  background: linear-gradient(90deg, transparent, #c8941e 30%, #e8b840 50%, #c8941e 70%, transparent);
}
.panel.hidden { opacity: 0; pointer-events: none; transform: translateX(20px); }

.panel-top {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(200,148,30,0.15);
}
.panel-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(10,6,2,0.6); border: 1px solid rgba(200,148,30,0.3);
  display: flex; align-items: center; justify-content: center;
  color: #7a5830; flex-shrink: 0;
}
.panel-titles { flex: 1; min-width: 0; }
.panel-level  { font-size: 10px; color: #c8941e; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.panel-name-preview { font-family: 'Cinzel', serif; font-size: 14px; color: #e8d090; font-weight: 600; margin-top: 2px; }
.panel-close { background: none; border: none; cursor: pointer; color: #6a4820; font-size: 16px; padding: 4px; border-radius: 4px; transition: color 0.15s; flex-shrink: 0; }
.panel-close:hover { color: #c8a870; }

.panel-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.field-group label { display: block; font-size: 10px; font-weight: 700; color: #8a6030; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 4px; }
.field-group input,
.field-group textarea {
  width: 100%; background: rgba(10,6,2,0.6);
  border: 1px solid rgba(160,100,20,0.35); border-radius: 8px;
  padding: 8px 11px; font-family: 'Nunito', sans-serif; font-size: 13px;
  color: #f0d9a0; outline: none; resize: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}
.field-group input::placeholder,
.field-group textarea::placeholder { color: #4a3018; }
.field-group input:focus,
.field-group textarea:focus {
  border-color: rgba(200,148,30,0.6);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), 0 0 0 3px rgba(200,148,30,0.1);
}

.panel-footer {
  display: flex; gap: 6px; padding: 12px 16px 14px;
  border-top: 1px solid rgba(200,148,30,0.15);
}
.btn-primary {
  flex: 1; padding: 9px; border: none; border-radius: 8px; cursor: pointer;
  background: linear-gradient(135deg, #c8941e, #8a6010);
  color: #1a0e04; font-family: 'Nunito', sans-serif; font-size: 13px; font-weight: 800;
  box-shadow: 0 3px 10px rgba(200,148,30,0.3); transition: opacity 0.15s, transform 0.1s;
}
.btn-primary:hover { opacity: 0.9; } .btn-primary:active { transform: scale(0.97); }
.btn-secondary {
  padding: 9px 12px; border: 1px solid rgba(160,100,20,0.35); border-radius: 8px;
  background: rgba(10,6,2,0.5); color: #a07840; cursor: pointer;
  font-family: 'Nunito', sans-serif; font-size: 13px; transition: all 0.15s;
}
.btn-secondary:hover { border-color: #c8941e; color: #e8b840; }
.btn-danger {
  padding: 9px 12px; border: 1px solid rgba(160,50,50,0.3); border-radius: 8px;
  background: rgba(10,2,2,0.5); color: #c07070; cursor: pointer;
  font-family: 'Nunito', sans-serif; font-size: 13px; transition: all 0.15s;
}
.btn-danger:hover { border-color: #c05050; color: #e08080; background: rgba(180,50,50,0.1); }

/* ===================== ADD HINT ===================== */
.add-hint {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #c8941e, #8a6010);
  color: #1a0e04; padding: 10px 20px; border-radius: 24px;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
  z-index: 200; box-shadow: 0 6px 24px rgba(200,148,30,0.4);
  animation: slideUp 0.3s ease;
}
.add-hint.hidden { display: none; }
.add-hint button { background: rgba(0,0,0,0.2); border: none; border-radius: 12px; color: #1a0e04; padding: 3px 10px; cursor: pointer; font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 700; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1e1208; border: 1px solid rgba(200,148,30,0.4);
  border-radius: 10px; padding: 10px 16px; font-size: 13px; color: #f0d9a0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5); z-index: 300;
  animation: slideUp 0.3s ease;
}
.toast.hidden { display: none; }

/* ===================== CORNER ORNAMENTS ===================== */
.scene-hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: #4a3018; pointer-events: none; white-space: nowrap;
  background: rgba(0,0,0,0.3); padding: 4px 14px; border-radius: 20px;
  border: 1px solid rgba(200,148,30,0.1); z-index: 5;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Ornament corners on scene */
#scene .orn {
  position: absolute; width: 80px; height: 80px; pointer-events: none; z-index: 5;
}
#scene .orn::before, #scene .orn::after {
  content: ''; position: absolute; border: 1px solid rgba(200,148,30,0.2);
}
#scene .orn::before { top: 8px; left: 8px; width: 44px; height: 44px; border-right: none; border-bottom: none; }
#scene .orn::after  { top: 18px; left: 18px; width: 26px; height: 26px; border-right: none; border-bottom: none; transform: rotate(45deg); transform-origin: top left; }
#scene .orn.tl { top: 0; left: 0; }
#scene .orn.tr { top: 0; right: 0; transform: scaleX(-1); }
#scene .orn.bl { bottom: 0; left: 0; transform: scaleY(-1); }
#scene .orn.br { bottom: 0; right: 0; transform: scale(-1); }

.hidden { display: none !important; }

/* ---- Add mode styles ---- */
.node-card.add-mode { cursor: pointer; }
.node-card.add-mode:hover .card-avatar {
  border-color: rgba(232,184,64,0.9);
  box-shadow: 0 0 20px rgba(200,148,30,0.5);
}
.add-plus {
  position: absolute; bottom: -4px; right: -4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, #c8941e, #8a6010);
  color: #1a0e04; font-size: 16px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

/* SVG and treeWrap transform-origin */
#branch-svg, #tree-wrap {
  transform-origin: center center;
  will-change: transform;
}

/* ---- Card edit/add buttons ---- */
.card-edit-btn, .card-add-btn {
  position: absolute;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid rgba(200,148,30,0.5);
  cursor: pointer; font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; opacity: 0;
  font-family: 'Nunito', sans-serif;
}
.node-card:hover .card-edit-btn,
.node-card:hover .card-add-btn { opacity: 1; }

.card-edit-btn {
  top: -8px; right: -8px;
  background: rgba(30,18,8,0.95); color: #c8941e;
}
.card-edit-btn:hover { background: #c8941e; color: #1a0e04; }

.card-add-btn {
  bottom: -8px; right: -8px;
  background: rgba(30,80,30,0.95); color: #70c870;
  border-color: rgba(80,180,80,0.5); font-size: 16px; font-weight: 900;
}
.card-add-btn:hover { background: #50a850; color: #fff; }

/* ---- Gender styles ---- */
.gender-male  .card-avatar { border-color: rgba(100,150,220,0.6); }
.gender-female .card-avatar { border-color: rgba(220,120,160,0.6); }
.avatar-male  { background: linear-gradient(135deg, #2a3050, #1a2030) !important; color: #8090d0; }
.avatar-female { background: linear-gradient(135deg, #502030, #301020) !important; color: #d080a0; }

/* ---- Card relation label ---- */
.card-relation {
  font-size: 9px; color: #c8941e; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 2px;
}

/* ---- Selected card ---- */
.node-card.selected .card-plaque {
  border-color: rgba(232,184,64,0.8);
  box-shadow: 0 0 16px rgba(200,148,30,0.3);
}

/* ---- Panel select & radio ---- */
.panel-body select {
  width: 100%; background: rgba(10,6,2,0.6);
  border: 1px solid rgba(160,100,20,0.35); border-radius: 8px;
  padding: 8px 11px; font-family: 'Nunito', sans-serif; font-size: 13px;
  color: #f0d9a0; outline: none; cursor: pointer;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237a5830' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.panel-body select:focus {
  border-color: rgba(200,148,30,0.6);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), 0 0 0 3px rgba(200,148,30,0.1);
}
.panel-body select option { background: #1e1208; color: #f0d9a0; }

.radio-group { display: flex; gap: 8px; }
.radio-opt { cursor: pointer; flex: 1; }
.radio-opt input[type=radio] { display: none; }
.radio-btn {
  display: block; text-align: center;
  padding: 7px 8px; border-radius: 8px; font-size: 12px; font-weight: 600;
  border: 1px solid rgba(160,100,20,0.35);
  background: rgba(10,6,2,0.5); color: #7a5830;
  transition: all 0.15s; cursor: pointer;
}
.radio-opt input[type=radio]:checked + .radio-btn.male {
  background: rgba(60,80,160,0.25); border-color: rgba(100,130,220,0.6); color: #9090e0;
}
.radio-opt input[type=radio]:checked + .radio-btn.female {
  background: rgba(160,60,100,0.25); border-color: rgba(220,100,150,0.6); color: #e090b0;
}

/* ---- Primary header button ---- */
.hdr-btn.primary {
  background: linear-gradient(135deg, #c8941e, #8a6010);
  border-color: transparent; color: #1a0e04; font-weight: 800;
}
.hdr-btn.primary:hover { opacity: 0.9; color: #1a0e04; }

/* ---- Role badges ---- */
.role-badge { font-size: 10px; padding: 2px 7px; border-radius: 8px; font-weight: 700; letter-spacing: 0.05em; }
.role-admin  { background: rgba(200,148,30,0.25); color: #e8b840; border: 1px solid rgba(200,148,30,0.3); }
.role-editor { background: rgba(80,120,200,0.2);  color: #90b0f0; border: 1px solid rgba(80,120,200,0.3); }
.role-user   { background: rgba(60,160,80,0.2);   color: #80d090; border: 1px solid rgba(60,160,80,0.3); }
.role-guest  { background: rgba(100,100,100,0.15);color: #909090; border: 1px solid rgba(100,100,100,0.2); }

/* ---- Admin link ---- */
a.hdr-btn { text-decoration: none; }

/* ---- External (merged-in) nodes — чужая ветвь ---- */
.node-ext .card-plaque {
  border-style: dashed;
  border-color: rgba(80,160,100,0.55);
  background: linear-gradient(160deg, #0e2010 0%, #0a1a0c 100%);
}
.node-ext .card-avatar {
  border-color: rgba(80,160,100,0.5);
  background: linear-gradient(135deg, #1a3020, #0e200e) !important;
}
.node-ext .card-name { color: #80d090; }
.node-ext .card-years { color: #4a8050; }
.node-ext .card-ru    { color: #3a6040; }
.node-ext::after {
  content: '🔗';
  position: absolute;
  top: -8px; left: -8px;
  font-size: 11px;
  background: rgba(20,60,30,0.95);
  border-radius: 50%;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(80,160,100,0.5);
}

/* ---- Same-person merged node — наш узел помечен как совпадающий ---- */
.node-merged-same .card-plaque {
  border-color: rgba(200,148,30,0.8);
  box-shadow: 0 0 12px rgba(200,148,30,0.2);
}
.node-merged-same::after {
  content: '=';
  position: absolute;
  top: -8px; left: -8px;
  font-size: 11px; font-weight: 900;
  background: rgba(200,148,30,0.9);
  color: #1a0e04;
  border-radius: 50%;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(232,184,64,0.6);
}

/* ---- Couple node (пара) ---- */
.node-couple .card-glow { inset: -14px; }

.couple-oval {
  display: flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #2a1a08, #1e1006);
  border: 1.5px solid rgba(200,148,30,0.6);
  border-radius: 50px;
  padding: 6px 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 20px rgba(200,148,30,0.1);
  margin-bottom: 6px;
}

.couple-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(200,148,30,0.4);
  flex-shrink: 0;
}
.couple-avatar.avatar-male   { background: linear-gradient(135deg,#2a3050,#1a2030); color:#8090d0; }
.couple-avatar.avatar-female { background: linear-gradient(135deg,#502030,#301020); color:#d080a0; }

.couple-heart {
  font-size: 14px;
  color: rgba(200,80,80,0.7);
  flex-shrink: 0;
  animation: heartbeat 2s ease-in-out infinite;
}
@keyframes heartbeat {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.2); color: rgba(220,60,60,0.9); }
}

.couple-plaque {
  min-width: 120px !important;
  max-width: 160px !important;
}
.couple-names {
  display: flex; align-items: center; gap: 4px;
  justify-content: center; flex-wrap: wrap;
}
.couple-sep {
  font-size: 10px; color: rgba(200,148,30,0.6); font-weight: 900;
}
.partner-name { color: #d090c0; }

/* ---- Photo upload in panel ---- */
.photo-upload-wrap {
  display: flex; align-items: center; gap: 12px;
}
.photo-preview {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(10,6,2,0.6);
  border: 1px solid rgba(160,100,20,0.4);
  display: flex; align-items: center; justify-content: center;
  color: #7a5830; flex-shrink: 0; overflow: hidden;
}
.photo-actions { display: flex; flex-direction: column; gap: 6px; }
.btn-photo-upload {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 7px; cursor: pointer; font-size: 12px;
  background: rgba(10,6,2,0.5); border: 1px solid rgba(160,100,20,0.4);
  color: #c8941e; font-family: 'Nunito', sans-serif; font-weight: 600;
  transition: all 0.15s;
}
.btn-photo-upload:hover { background: rgba(200,148,30,0.15); border-color: #c8941e; }
.btn-photo-delete {
  padding: 5px 10px; border-radius: 7px; cursor: pointer; font-size: 11px;
  background: rgba(160,40,40,0.15); border: 1px solid rgba(160,40,40,0.3);
  color: #c06060; font-family: 'Nunito', sans-serif; transition: all 0.15s;
}
.btn-photo-delete:hover { background: rgba(180,50,50,0.3); }
