/* ================================================================
   VILLAGE FAMILY TREE — DESIGN SYSTEM
   Modern, professional, fully theme-aware
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=Inter:wght@300;400;500;600&display=swap');

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img, video { max-width: 100%; display: block; }
input, button, textarea, select { font: inherit; }

/* ================================================================
   DESIGN TOKENS — Dark mode (default)
   ================================================================ */
:root {
  /* Backgrounds */
  --bg:        #080b14;
  --bg2:       #0d1020;
  --bg3:       #111426;
  --surface:   #161929;
  --surface2:  #1b1e32;
  --overlay:   rgba(8,11,20,.85);

  /* Borders */
  --border:    rgba(255,255,255,.07);
  --border2:   rgba(255,255,255,.13);
  --border-focus: rgba(232,201,122,.45);

  /* Text */
  --text:        #eae6db;
  --text-muted:  #7a7f9a;
  --text-dim:    #44485e;
  --text-inv:    #080b14;

  /* Accent — Gold */
  --gold:        #e8c97a;
  --gold-bright: #f0d890;
  --gold-dim:    #9a7a38;
  --gold-glow:   rgba(232,201,122,.18);
  --gold-subtle: rgba(232,201,122,.06);

  /* Semantic colours */
  --success-bg:   rgba(26,90,60,.4);
  --success-border:rgba(40,160,100,.3);
  --success-text: #6ae8a8;
  --danger-bg:    rgba(90,26,26,.4);
  --danger-border:rgba(180,60,60,.3);
  --danger-text:  #f48a8a;
  --info-bg:      rgba(26,50,100,.4);
  --info-border:  rgba(60,100,200,.3);
  --info-text:    #90b4f8;
  --warn-bg:      rgba(80,60,10,.4);
  --warn-border:  rgba(180,140,30,.3);
  --warn-text:    #f0d478;

  /* Node colours (tree) */
  --node-blue:    #1e5aaa;
  --node-pink:    #a03068;
  --node-amber:   #a06820;
  --node-purple:  #5a4a9a;
  --node-pending: #2e3348;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.5);
  --shadow-sm:  0 2px 8px rgba(0,0,0,.35);
  --shadow-md:  0 4px 20px rgba(0,0,0,.4);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.5);
  --shadow-xl:  0 16px 64px rgba(0,0,0,.6);
  --shadow-glow:0 0 24px rgba(232,201,122,.12);

  /* Radii */
  --r-xs:  4px;
  --r-sm:  8px;
  --r:     12px;
  --r-lg:  16px;
  --r-xl:  20px;
  --r-2xl: 28px;

  /* Layout */
  --nav-h:    58px;
  --nav-bg:   rgba(8,11,20,.9);
  --sidebar-w:240px;

  /* Transitions */
  --ease:     cubic-bezier(.4,0,.2,1);
  --t-fast:   150ms;
  --t-base:   200ms;
  --t-slow:   350ms;
}

/* ================================================================
   LIGHT MODE TOKENS
   ================================================================ */
[data-theme="light"] {
  --bg:        #f2f4fb;
  --bg2:       #e8ebf5;
  --bg3:       #dfe3f0;
  --surface:   #ffffff;
  --surface2:  #f8f9fe;
  --overlay:   rgba(242,244,251,.9);

  --border:    rgba(0,0,0,.08);
  --border2:   rgba(0,0,0,.15);
  --border-focus: rgba(154,112,32,.45);

  --text:        #16192e;
  --text-muted:  #626680;
  --text-dim:    #a0a4be;
  --text-inv:    #ffffff;

  --gold:        #9a7020;
  --gold-bright: #b88828;
  --gold-dim:    #7a5618;
  --gold-glow:   rgba(154,112,32,.15);
  --gold-subtle: rgba(154,112,32,.05);

  --success-bg:   rgba(220,250,235,.8);
  --success-border:rgba(40,160,100,.25);
  --success-text: #145228;
  --danger-bg:    rgba(255,230,230,.8);
  --danger-border:rgba(200,60,60,.25);
  --danger-text:  #7a1414;
  --info-bg:      rgba(225,235,255,.8);
  --info-border:  rgba(60,100,220,.2);
  --info-text:    #1a3080;
  --warn-bg:      rgba(255,248,220,.8);
  --warn-border:  rgba(200,160,30,.25);
  --warn-text:    #604000;

  --shadow-xs:  0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:  0 2px 8px rgba(0,0,0,.07);
  --shadow-md:  0 4px 20px rgba(0,0,0,.08);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.1);
  --shadow-xl:  0 16px 64px rgba(0,0,0,.12);
  --shadow-glow:0 0 24px rgba(154,112,32,.1);

  --nav-bg:   rgba(255,255,255,.92);
}

/* ================================================================
   BASE
   ================================================================ */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-base) var(--ease),
              color var(--t-base) var(--ease);
}

/* Ambient gradient field behind every page (premium glass look) */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(58% 58% at 16% 24%, rgba(122,90,255,.18) 0%, transparent 60%),
    radial-gradient(48% 48% at 86% 78%, rgba(232,201,122,.12) 0%, transparent 60%),
    radial-gradient(72% 72% at 50% 118%, rgba(122,90,255,.10) 0%, transparent 55%);
}
[data-theme="light"] body::before {
  background:
    radial-gradient(58% 58% at 16% 24%, rgba(122,90,255,.10) 0%, transparent 60%),
    radial-gradient(48% 48% at 86% 78%, rgba(154,112,32,.10) 0%, transparent 60%);
}

/* Smooth theme transitions on everything */
*, *::before, *::after {
  transition-property: background-color, border-color, color, box-shadow, opacity;
  transition-duration: var(--t-base);
  transition-timing-function: var(--ease);
}
/* Exclude transitions that should be instant */
svg *, canvas, img, video,
.ft-node *, [class*="tree-"],
input[type="range"],
.transition-none { transition: none !important; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar            { width: 5px; height: 5px; }
::-webkit-scrollbar-track      { background: var(--bg2); }
::-webkit-scrollbar-thumb      { background: var(--border2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover{ background: var(--text-dim); }

/* ── SELECTION ── */
::selection { background: var(--gold-glow); color: var(--text); }

/* ================================================================
   PARTICLES
   ================================================================ */
#particles-canvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: .3;
}
[data-theme="light"] #particles-canvas { opacity: .12; }

/* ================================================================
   LAYOUT HELPERS
   ================================================================ */
.unav, .page-body, .page-wrap, .admin-wrap,
.tree-page, .landing, .right, .left, nav {
  position: relative; z-index: 1;
}
.page-body  { padding-top: var(--nav-h); min-height: 100vh; }
.page-wrap  { padding-top: var(--nav-h); min-height: 100vh; }
.container  { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }
.section    { padding: 2rem 0; }

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: rgba(22,25,41,.55);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.05);
}
[data-theme="light"] .card {
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-color: rgba(0,0,0,.06);
  box-shadow: 0 4px 24px rgba(0,0,0,.08), inset 0 1px 0 rgba(255,255,255,.6);
}
.card-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.1rem; font-weight: 600;
  color: var(--text);
  margin-bottom: .85rem;
}
.card-glass {
  background: rgba(22,25,41,.55);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid var(--border2);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
}
[data-theme="light"] .card-glass {
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1.25rem; border-radius: var(--r);
  min-height: 40px; font-size: .875rem; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  text-decoration: none; white-space: nowrap;
  position: relative; overflow: hidden;
  letter-spacing: .01em;
}
.btn::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--t-fast) var(--ease);
}
.btn:hover::after   { background: rgba(255,255,255,.06); }
.btn:active::after  { background: rgba(255,255,255,.12); }

.btn-gold {
  background: linear-gradient(135deg, var(--gold-bright) 0%, var(--gold) 55%, var(--gold-dim) 120%);
  color: #1a1206; border-color: var(--gold);
  box-shadow: 0 8px 24px var(--gold-glow);
  font-weight: 700;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease), filter var(--t-base) var(--ease);
}
.btn-gold:hover { box-shadow: 0 12px 32px var(--gold-glow); transform: translateY(-1px); filter: brightness(1.04); }
.btn-gold:active { transform: translateY(0); }
[data-theme="light"] .btn-gold { color: #160e00; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border2);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); background: var(--surface2); }

.btn-danger  { background: transparent; color: var(--danger-text); border-color: var(--danger-border); }
.btn-danger:hover  { background: var(--danger-bg); }
.btn-success { background: transparent; color: var(--success-text); border-color: var(--success-border); }
.btn-success:hover { background: var(--success-bg); }

.btn-sm  { padding: .4rem .85rem; font-size: .8rem; min-height: 34px; border-radius: var(--r-sm); }
.btn-lg  { padding: .75rem 1.6rem; font-size: 1rem; min-height: 48px; border-radius: var(--r-lg); }
.btn-block { width: 100%; }

/* ================================================================
   FORM CONTROLS
   ================================================================ */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-size: .8rem; font-weight: 500;
  color: var(--text-muted); margin-bottom: 6px; letter-spacing: .01em;
}
.form-control {
  width: 100%;
  background: var(--bg2);
  border: 1.5px solid var(--border2);
  border-radius: var(--r);
  padding: .65rem 1rem;
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              background var(--t-base) var(--ease);
  -webkit-appearance: none; appearance: none;
}
.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--gold-glow);
  background: var(--surface);
}
.form-control::placeholder   { color: var(--text-dim); }
[data-theme="light"] .form-control { background: var(--surface); border-color: var(--border2); }
[data-theme="light"] .form-control:focus { background: var(--surface); }
[data-theme="light"] .form-control::placeholder { color: var(--text-dim); }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a7f9a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}
select.form-control option { background: var(--surface); color: var(--text); }
textarea.form-control { resize: vertical; min-height: 90px; line-height: 1.6; }

/* ================================================================
   ALERTS
   ================================================================ */
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--r);
  font-size: .875rem;
  margin-bottom: 1rem;
  line-height: 1.6;
  border: 1px solid;
  display: flex; align-items: flex-start; gap: .6rem;
}
.alert-error   { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger-text); }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.alert-info    { background: var(--info-bg);    border-color: var(--info-border);    color: var(--info-text); }
.alert-warn    { background: var(--warn-bg);    border-color: var(--warn-border);    color: var(--warn-text); }

/* ================================================================
   BADGES
   ================================================================ */
.badge {
  display: inline-flex; align-items: center;
  font-size: .7rem; font-weight: 600;
  padding: 2px 9px; border-radius: 99px;
  letter-spacing: .02em;
}
.badge-pending   { background: rgba(74,78,110,.25);  color: var(--text-muted); border: 1px solid rgba(74,78,110,.4); }
.badge-approved,
.badge-active    { background: var(--success-bg);  color: var(--success-text); border: 1px solid var(--success-border); }
.badge-rejected  { background: var(--danger-bg);   color: var(--danger-text);  border: 1px solid var(--danger-border); }
.badge-suspended { background: var(--warn-bg);     color: var(--warn-text);    border: 1px solid var(--warn-border); }
.badge-superadmin{ background: rgba(38,33,92,.6);  color: #AFA9EC; border: 1px solid rgba(100,90,180,.4); }
.badge-admin     { background: rgba(42,26,58,.6);  color: #c4a0f0; border: 1px solid rgba(140,90,200,.3); }
.badge-editor    { background: rgba(26,42,26,.6);  color: #8ad48a; border: 1px solid rgba(80,160,80,.3); }
.badge-viewer    { background: rgba(26,26,50,.6);  color: #9090c8; border: 1px solid rgba(80,80,160,.3); }

[data-theme="light"] .badge-pending    { background: rgba(100,105,160,.08); color: #606480; border-color: rgba(100,105,160,.2); }
[data-theme="light"] .badge-superadmin { background: rgba(80,70,180,.08);   color: #5040a8; border-color: rgba(80,70,180,.2); }
[data-theme="light"] .badge-admin      { background: rgba(120,60,180,.08);  color: #7030a0; border-color: rgba(120,60,180,.2); }
[data-theme="light"] .badge-editor     { background: rgba(40,120,40,.08);   color: #206820; border-color: rgba(40,120,40,.2); }
[data-theme="light"] .badge-viewer     { background: rgba(60,60,160,.08);   color: #303890; border-color: rgba(60,60,160,.2); }

/* ================================================================
   TABLES
   ================================================================ */
.table-wrap  { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-lg); }
.data-table  { width: 100%; border-collapse: collapse; font-size: .875rem; min-width: 480px; }
.data-table th {
  text-align: left; font-size: .75rem; font-weight: 600;
  color: var(--text-muted); padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap; background: var(--surface2);
}
.data-table th:first-child { border-radius: var(--r-lg) 0 0 0; }
.data-table th:last-child  { border-radius: 0 var(--r-lg) 0 0; }
.data-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface2); }

/* ================================================================
   ADMIN LAYOUT
   ================================================================ */
.admin-wrap  { display: flex; min-height: calc(100vh - var(--nav-h)); }
.admin-sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  display: none;
  box-shadow: 2px 0 12px rgba(0,0,0,.15);
}
[data-theme="light"] .admin-sidebar { box-shadow: 2px 0 12px rgba(0,0,0,.04); }
.admin-main  { flex: 1; padding: 1.5rem; min-width: 0; background: var(--bg); }

.admin-link, .sl {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem 1.1rem; font-size: .85rem; font-weight: 500;
  color: var(--text-muted); text-decoration: none;
  margin: 1px .5rem; border-radius: var(--r-sm);
  transition: all var(--t-fast) var(--ease);
}
.admin-link:hover, .admin-link.active,
.sl:hover, .sl.on {
  color: var(--text); background: var(--surface2);
}
.admin-link.active, .sl.on { color: var(--gold); }
.admin-link .badge, .sl .badge { margin-left: auto; }

/* ================================================================
   TREE PAGE
   ================================================================ */
.tree-page  { display: flex; height: calc(100vh - var(--nav-h)); overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: none; flex-direction: column; overflow: hidden;
}
.sidebar-header { padding: 1rem; border-bottom: 1px solid var(--border); }
.sidebar-body   { flex: 1; overflow-y: auto; padding: .5rem; }
.tree-canvas    { flex: 1; position: relative; overflow: hidden; background: var(--bg); }
[data-theme="light"] .tree-canvas { background: var(--bg); }
#tree-svg       { width: 100%; height: 100%; }

/* Tree controls */
.tree-controls {
  position: absolute; bottom: 132px; right: 1.25rem; /* lifted above the chat launcher + Find-relationship button (desktop) */
  display: flex; flex-direction: column; gap: .5rem; z-index: 10;
}
.ctrl-btn {
  width: 42px; height: 42px;
  border-radius: var(--r);
  background: rgba(22,25,41,.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border2);
  color: var(--text-muted); cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--t-fast) var(--ease);
}
.ctrl-btn:hover { border-color: var(--gold); color: var(--gold); box-shadow: var(--shadow-glow); }

/* Legend */
.legend {
  position: absolute; bottom: 1.25rem; left: 1.25rem;
  background: rgba(8,11,20,.8);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg); padding: .85rem 1.1rem;
  z-index: 10; display: none;
}
.legend-item { display: flex; align-items: center; gap: .5rem; font-size: .72rem; color: var(--text-muted); margin-bottom: .3rem; }
.legend-item:last-child { margin-bottom: 0; }
.legend-dot  { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* Path bar */
.path-bar {
  position: absolute; top: 1rem; left: 50%; transform: translateX(-50%);
  background: rgba(8,11,20,.88);
  backdrop-filter: blur(12px);
  border: 1px solid var(--gold-dim);
  border-radius: 99px; padding: .5rem 1.1rem;
  font-size: .8rem; color: var(--gold);
  display: none; align-items: center; gap: .5rem;
  white-space: nowrap; max-width: calc(100vw - 2rem);
  overflow: hidden; text-overflow: ellipsis; z-index: 10;
  box-shadow: var(--shadow-glow);
}
.path-bar.visible        { display: flex; }
.path-bar-close          { cursor: pointer; color: var(--text-muted); margin-left: .5rem; }

/* Profile panel */
.profile-panel {
  width: 100%; max-width: 320px; flex-shrink: 0;
  background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  position: fixed; right: 0; top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  transform: translateX(100%); transition: transform var(--t-slow) var(--ease);
  z-index: 150; box-shadow: var(--shadow-xl);
}
.profile-panel.open        { transform: translateX(0); }
.profile-header            { padding: 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.profile-body              { flex: 1; overflow-y: auto; }
.profile-section           { padding: 1rem; border-bottom: 1px solid var(--border); }
.profile-label             { font-size: .72rem; color: var(--text-muted); margin-bottom: .2rem; font-weight: 500; }
.profile-value             { font-size: .875rem; color: var(--text); }
.profile-name              { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 1.3rem; font-weight: 600; color: var(--text); }
.profile-photo             { width: 100%; height: 150px; object-fit: cover; background: var(--surface2); }
.profile-photo-placeholder { width: 100%; height: 150px; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; color: var(--border2); }

/* Member list */
.member-item      { display: flex; align-items: center; gap: .65rem; padding: .55rem .6rem; border-radius: var(--r-sm); cursor: pointer; transition: background var(--t-fast) var(--ease); }
.member-item:hover{ background: var(--surface2); }
.member-dot       { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; }
.member-name      { font-size: .85rem; color: var(--text); font-weight: 500; }
.member-sub       { font-size: .72rem; color: var(--text-muted); }

/* Relationship chips */
.rel-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .7rem; border-radius: 99px;
  background: var(--surface2); border: 1px solid var(--border2);
  font-size: .75rem; color: var(--text-muted);
  cursor: pointer; margin: .2rem;
  transition: all var(--t-fast) var(--ease);
}
.rel-chip:hover { border-color: var(--gold); color: var(--gold); }

/* Search bar */
.search-wrap        { position: relative; display: flex; align-items: center; }
.search-wrap input  {
  background: var(--bg2); border: 1.5px solid var(--border2);
  border-radius: var(--r); padding: .55rem .85rem .55rem 2.2rem;
  color: var(--text); font-size: .875rem; outline: none; width: 100%;
  transition: border-color var(--t-fast) var(--ease), background var(--t-base) var(--ease);
}
.search-wrap input:focus { border-color: var(--border-focus); background: var(--surface); }
.search-icon        { position: absolute; left: .7rem; color: var(--text-muted); pointer-events: none; }

/* ================================================================
   NODE COLOURS
   ================================================================ */
.node-blue   { fill: var(--node-blue);   stroke: #4a90e8; }
.node-pink   { fill: var(--node-pink);   stroke: #e870a0; }
.node-amber  { fill: var(--node-amber);  stroke: #e8a030; }
.node-purple { fill: var(--node-purple); stroke: #9080d8; }
.node-default{ fill: #1e2440;           stroke: #4a5080; }
.node-pending{ fill: var(--node-pending); stroke: #5a6090; stroke-dasharray: 5 3; opacity: .55; }
.ft-node     { cursor: pointer; }
.ft-node:hover .node-card     { filter: brightness(1.2); }
.ft-node.selected .node-card  { filter: brightness(1.4); }
.ft-node.on-path .node-card   { filter: brightness(1.3) drop-shadow(0 0 6px #e8c97a); }
.node-card   { transition: filter .2s; }
.node-name   { font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 500; }
.node-sub    { font-family: 'Inter', sans-serif; font-size: 9px; fill: rgba(255,255,255,.55); }

/* ================================================================
   STAT CARDS (admin)
   ================================================================ */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-num   { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 2.2rem; font-weight: 700; color: var(--gold); line-height: 1; }
.stat-num.warn { color: var(--warn-text); }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: .4rem; font-weight: 500; }
[data-theme="light"] .stat-card { box-shadow: 0 2px 12px rgba(0,0,0,.06); }

/* ================================================================
   SECTION HEADING
   ================================================================ */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; flex-wrap: wrap; gap: .5rem;
}
.section-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.2rem; font-weight: 600; color: var(--text);
}
.sect-divider {
  display: flex; align-items: center; gap: .75rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.3rem; font-weight: 600; color: var(--gold);
  margin: 2rem 0 1rem;
}
.sect-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ================================================================
   FLASH / TOAST
   ================================================================ */
.flash {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: var(--r-lg);
  padding: .85rem 1.1rem;
  font-size: .875rem; color: var(--success-text);
  margin-bottom: 1.25rem;
  display: flex; align-items: center; gap: .6rem;
}
.flash.error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }

/* ================================================================
   GRID HELPERS
   ================================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.stats-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: .85rem; margin-bottom: 1.5rem; }

/* ================================================================
   CODE ELEMENTS
   ================================================================ */
code {
  font-size: .82em; font-family: 'Menlo','Cascadia Code','Fira Code',monospace;
  background: var(--bg2); color: var(--gold);
  padding: 2px 7px; border-radius: var(--r-xs);
  border: 1px solid var(--border);
}

/* ================================================================
   RESPONSIVE — Tablet 640px+
   ================================================================ */
@media (min-width: 640px) {
  .container  { padding: 0 1.5rem; }
  .card       { padding: 1.5rem; }
  .grid-2     { grid-template-columns: 1fr 1fr; }
  .grid-4     { grid-template-columns: repeat(4,1fr); }
  .stats-grid { grid-template-columns: repeat(3,1fr); }
}

/* ================================================================
   RESPONSIVE — Desktop 900px+
   ================================================================ */
@media (min-width: 900px) {
  .admin-sidebar { display: block; }
  .sidebar       { display: flex; }
  .grid-3        { grid-template-columns: 1fr 1fr 1fr; }
  .stats-grid    { grid-template-columns: repeat(5,1fr); }
  .legend        { display: block; }
}

/* ================================================================
   RESPONSIVE — Wide 1200px+
   ================================================================ */
@media (min-width: 1200px) {
  .container  { padding: 0 2rem; }
  .admin-main { padding: 2rem; }
}

/* ── Accessibility: visible keyboard focus ring ──────────────────
   Only shows for keyboard navigation (:focus-visible), so mouse/touch
   focus stays clean. Applies app-wide. */
:focus-visible {
  outline: 2px solid var(--gold, #e8c97a);
  outline-offset: 2px;
  border-radius: 3px;
}
a:focus-visible, button:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--gold, #e8c97a);
  outline-offset: 2px;
}
