/* ==========================================================================
   Interactive Family Tree Platform (fam3) - Black & White Theme
   Ultra-Premium Monochrome / Noir & Ink Aesthetic
   ========================================================================== */

:root {
  /* Black & White Noir Palette (Default) */
  --bg-primary: #050505;
  --bg-secondary: #0f0f0f;
  --bg-tertiary: #1c1c1c;
  --bg-glass: rgba(15, 15, 15, 0.88);
  --bg-glass-hover: rgba(30, 30, 30, 0.95);
  --bg-card: rgba(18, 18, 18, 0.95);
  --bg-card-hover: #1f1f1f;

  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --text-muted: #888888;
  --text-inverse: #000000;

  --accent-primary: #ffffff;
  --accent-primary-hover: #e5e5e5;
  --accent-primary-glow: rgba(255, 255, 255, 0.25);

  --accent-male: #ffffff;
  --accent-male-gradient: linear-gradient(135deg, #2a2a2a, #737373);
  --accent-male-border: rgba(255, 255, 255, 0.5);

  --accent-female: #ffffff;
  --accent-female-gradient: linear-gradient(135deg, #404040, #a3a3a3);
  --accent-female-border: rgba(255, 255, 255, 0.5);

  --accent-other: #ffffff;
  --accent-other-gradient: linear-gradient(135deg, #171717, #525252);
  --accent-other-border: rgba(255, 255, 255, 0.5);

  --accent-living: #ffffff;
  --accent-deceased: #555555;
  --accent-gold: #ffffff;

  --border-color: rgba(255, 255, 255, 0.2);
  --border-color-strong: rgba(255, 255, 255, 0.6);
  --connector-stroke: #ffffff;
  --connector-stroke-active: #ffffff;

  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.8);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.95);
  --shadow-glow: 0 0 20px rgba(255, 255, 255, 0.2);

  --card-width: 240px;
  --card-height: 126px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Mode: Classic Ink & White Paper Theme */
[data-theme="light"] {
  --bg-primary: #f4f4f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e4e4e7;
  --bg-glass: rgba(255, 255, 255, 0.92);
  --bg-glass-hover: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #fcfcfc;

  --text-primary: #09090b;
  --text-secondary: #3f3f46;
  --text-muted: #71717a;
  --text-inverse: #ffffff;

  --accent-primary: #09090b;
  --accent-primary-hover: #27272a;
  --accent-primary-glow: rgba(0, 0, 0, 0.15);

  --accent-male-border: rgba(0, 0, 0, 0.4);
  --accent-male-gradient: linear-gradient(135deg, #e4e4e7, #a1a1aa);

  --accent-female-border: rgba(0, 0, 0, 0.4);
  --accent-female-gradient: linear-gradient(135deg, #d4d4d8, #71717a);

  --accent-other-border: rgba(0, 0, 0, 0.4);
  --accent-other-gradient: linear-gradient(135deg, #e4e4e7, #52525b);

  --border-color: rgba(0, 0, 0, 0.18);
  --border-color-strong: rgba(0, 0, 0, 0.5);
  --connector-stroke: #09090b;
  --connector-stroke-active: #000000;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.14);
  --shadow-glow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Header & Navbar Layout (Black & White)
   ========================================================================== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  text-transform: uppercase;
}

.brand-badge {
  font-size: 0.68rem;
  padding: 3px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Header Center: Search */
.header-center {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  max-width: 500px;
  margin: 0 20px;
}

.search-wrapper {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 14px;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 38px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.88rem;
  transition: var(--transition-fast);
  outline: none;
}

.search-input:focus {
  border-color: var(--text-primary);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 380px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 150;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: var(--transition-fast);
  border-bottom: 1px solid var(--border-color);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--bg-tertiary);
}

/* Header Right: Controls & Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-switcher {
  display: flex;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.view-btn {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.view-btn:hover {
  color: var(--text-primary);
}

.view-btn.active {
  background: var(--text-primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-normal);
  font-family: inherit;
}

.btn-primary {
  background: var(--text-primary);
  color: var(--text-inverse);
  box-shadow: 0 4px 14px rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .btn-primary {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-color-strong);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  border-color: var(--border-color-strong);
  background: var(--bg-glass-hover);
}

/* ==========================================================================
   Workspace & Canvas Layout
   ========================================================================== */
.main-workspace {
  position: absolute;
  top: 68px;
  bottom: 0;
  left: 0;
  right: 0;
  overflow: hidden;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(var(--border-color) 1px, transparent 1px);
  background-size: 28px 28px;
}

.canvas-viewport {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.canvas-viewport.is-dragging {
  cursor: grabbing;
}

.canvas-plane {
  position: absolute;
  top: 0;
  left: 0;
  width: 10000px;
  height: 10000px;
  transform-origin: 0 0;
  will-change: transform;
}

/* SVG Line Connectors Layer (Literal Tree Branches) */
.connectors-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 10000px;
  height: 10000px;
  pointer-events: none;
  overflow: visible !important;
  z-index: 10;
}

.connector-path {
  fill: none;
  stroke: var(--connector-stroke);
  stroke-width: 3px;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.4));
  transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

[data-theme="light"] .connector-path {
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.2));
}

.connector-path.spouse-line {
  stroke: var(--connector-stroke);
  stroke-dasharray: 6 5;
  stroke-width: 2.5px;
}

.connector-path.active,
.connector-path:hover {
  stroke-width: 4.5px;
}

/* Union Marker (Ring connecting married partners) */
.union-marker {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 3px solid var(--connector-stroke);
  transform: translate(-50%, -50%);
  z-index: 15;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* ==========================================================================
   Node Cards (Black & White Portrait Style)
   ========================================================================== */
.nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
}

.node-card {
  position: absolute;
  width: var(--card-width);
  min-height: var(--card-height);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-color);
  box-shadow: var(--shadow-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.node-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-color-strong);
  z-index: 30 !important;
}

.node-card.focused {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5), var(--shadow-lg);
  animation: pulseHighlight 2s infinite;
}

/* Card Header */
.card-header-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* Large Portrait Avatar (Black & White style) */
.avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.avatar-img, .avatar-monogram {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  color: #ffffff;
  border: 2px solid var(--border-color-strong);
  background: var(--bg-tertiary);
  box-shadow: var(--shadow-sm);
  filter: grayscale(100%);
  transition: filter 0.3s ease, transform 0.3s ease;
}

.node-card:hover .avatar-img {
  filter: grayscale(0%);
}

.avatar-monogram {
  background: linear-gradient(135deg, #262626, #525252);
}

/* Status Indicator Dot */
.status-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.status-badge.living {
  background: #ffffff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

.status-badge.deceased {
  background: #525252;
}

[data-theme="light"] .status-badge.living {
  background: #000000;
}

/* Member Text Info */
.member-info {
  flex: 1;
  min-width: 0;
}

.member-name {
  font-family: var(--font-heading);
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-maiden {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.member-lifespan {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.member-role {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Card Bottom Metadata / Badges */
.card-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.generation-tag {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 700;
  border: 1px solid var(--border-color);
}

.children-count-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Quick Action Bar on Card Hover */
.card-actions-overlay {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-full);
  padding: 3px 6px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-fast);
  z-index: 50;
}

.node-card:hover .card-actions-overlay {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.card-action-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.card-action-btn:hover {
  background: var(--text-primary);
  color: var(--text-inverse);
  transform: scale(1.15);
}

/* Branch Collapse/Expand Button */
.collapse-branch-btn {
  position: absolute;
  bottom: -12px;
  right: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  color: var(--text-primary);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
  z-index: 35;
}

.collapse-branch-btn:hover {
  background: var(--text-primary);
  color: var(--text-inverse);
}

/* ==========================================================================
   Floating Controls & Minimap
   ========================================================================== */
.floating-controls {
  position: fixed;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  z-index: 90;
}

.floating-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.floating-btn:hover {
  background: var(--text-primary);
  color: var(--text-inverse);
  transform: scale(1.05);
}

.floating-divider {
  height: 1px;
  background: var(--border-color);
  margin: 2px 4px;
}

.minimap-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 200px;
  height: 130px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 90;
  cursor: crosshair;
}

.minimap-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.minimap-viewport-box {
  position: absolute;
  border: 2px solid var(--text-primary);
  background: rgba(255, 255, 255, 0.15);
  pointer-events: none;
  border-radius: 4px;
}

/* ==========================================================================
   Person Details Slide-Over Drawer
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 90vw;
  background: var(--bg-secondary);
  box-shadow: var(--shadow-lg);
  border-left: 1px solid var(--border-color-strong);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-smooth);
  z-index: 210;
}

.drawer-backdrop.open .drawer-panel {
  transform: translateX(0);
}

.drawer-header-cover {
  height: 130px;
  background: linear-gradient(135deg, #171717, #333333, #0a0a0a);
  border-bottom: 1px solid var(--border-color);
  position: relative;
  padding: 16px;
  display: flex;
  justify-content: flex-end;
}

.drawer-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-color);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.drawer-close-btn:hover {
  background: var(--text-primary);
  color: var(--text-inverse);
  transform: scale(1.1);
}

.drawer-profile-section {
  padding: 0 24px 20px;
  margin-top: -45px;
  position: relative;
}

.drawer-avatar-wrapper {
  position: relative;
  display: inline-block;
}

.drawer-avatar {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-full);
  border: 4px solid var(--bg-secondary);
  object-fit: cover;
  box-shadow: var(--shadow-md);
  filter: grayscale(100%);
}

.drawer-avatar:hover {
  filter: grayscale(0%);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 24px;
}

.drawer-name {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 10px;
  color: var(--text-primary);
}

.drawer-maiden {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.drawer-lifespan {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.drawer-quick-actions {
  display: flex;
  gap: 8px;
  margin: 18px 0;
}

.drawer-section {
  margin-top: 22px;
}

.drawer-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.drawer-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.drawer-info-item {
  background: var(--bg-tertiary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.drawer-info-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.drawer-info-value {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 600;
  margin-top: 2px;
}

.drawer-bio-text {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

/* Relatives List in Drawer */
.relatives-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.relative-card-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition-fast);
}

.relative-card-mini:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-color-strong);
  transform: translateX(3px);
}

.relative-mini-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.relative-mini-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.relative-mini-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Modals (Add / Edit / Stats / Import)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  padding: 20px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-smooth);
  overflow: hidden;
}

.modal-overlay.open .modal-card {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

/* Form Controls */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-group-full {
  grid-column: span 2;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: var(--transition-fast);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--text-primary);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Photo Upload Box (Supports up to 10MB) */
.avatar-upload-container {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--border-color-strong);
}

.avatar-preview-box {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-color-strong);
}

.avatar-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Radio Switches */
.radio-group {
  display: flex;
  gap: 12px;
}

.radio-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition-fast);
}

.radio-pill input {
  cursor: pointer;
}

.radio-pill:has(input:checked) {
  border-color: var(--text-primary);
  background: var(--text-primary);
  color: var(--text-inverse);
}

/* ==========================================================================
   Directory View
   ========================================================================== */
.directory-view {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 32px 24px;
  display: none;
  background: var(--bg-primary);
  z-index: 50;
}

.directory-view.active {
  display: block;
}

.directory-header {
  max-width: 1200px;
  margin: 0 auto 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.directory-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.directory-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  gap: 14px;
  cursor: pointer;
  transition: var(--transition-normal);
}

.directory-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-color-strong);
  box-shadow: var(--shadow-md);
}

/* Statistics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  text-align: center;
}

.stat-number {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-top: 4px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 500;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Responsive */
@media (max-width: 900px) {
  .brand-badge {
    display: none;
  }
  .header-center {
    max-width: 280px;
  }
  .view-btn span {
    display: none;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 0 12px;
  }
  .brand-title {
    display: none;
  }
  .header-center {
    margin: 0 8px;
  }
  .minimap-container {
    display: none;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-group-full {
    grid-column: span 1;
  }
}
