/* ============================================
   FAMILY TREE - Light Green Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Playfair+Display:wght@600;700&display=swap');

:root {
  /* Colors - Light Green Theme */
  --bg-primary: #f5f8f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef3ee;
  --surface: #ffffff;
  --surface-hover: #f0f5f0;
  --surface-active: #e8efe8;
  --border: #dce5dc;
  --border-hover: #b8c8b8;

  --text-primary: #1e3322;
  --text-secondary: #52705a;
  --text-tertiary: #8a9f8e;

  --green-900: #1b4332;
  --green-800: #2d6a4f;
  --green-700: #3a7d5c;
  --green-600: #40916c;
  --green-500: #52b788;
  --green-400: #74c69d;
  --green-300: #95d5b2;
  --green-200: #b7e4c7;
  --green-100: #d8f3dc;
  --green-50: #edf7ef;

  --male: #3a8078;
  --male-bg: #e8f3f1;
  --male-border: #a0cdc6;
  --female: #b07a55;
  --female-bg: #f5ede6;
  --female-border: #d4b99a;

  --success: #2d8a5e;
  --warning: #c78c1e;
  --danger: #c0392b;

  /* Spacing */
  --card-width: 200px;
  --card-height: 92px;
  --spouse-gap: 36px;
  --sibling-gap: 44px;
  --generation-gap: 130px;

  /* Borders */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(30, 51, 34, 0.06), 0 1px 2px rgba(30, 51, 34, 0.04);
  --shadow-md: 0 4px 12px rgba(30, 51, 34, 0.08), 0 2px 4px rgba(30, 51, 34, 0.04);
  --shadow-lg: 0 10px 30px rgba(30, 51, 34, 0.1), 0 4px 8px rgba(30, 51, 34, 0.05);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-index */
  --z-tree: 1;
  --z-connections: 2;
  --z-nodes: 3;
  --z-toolbar: 100;
  --z-context-menu: 200;
  --z-modal-backdrop: 300;
  --z-modal: 301;
  --z-toast: 400;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* ============================================
   Background
   ============================================ */
.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg-primary);
  pointer-events: none;
}

.bg-dots {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: radial-gradient(circle, rgba(45, 106, 79, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

/* ============================================
   Toolbar
   ============================================ */
.toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  z-index: var(--z-toolbar);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  background: var(--green-900);
  color: #ffffff;
}

.toolbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.toolbar-logo-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.toolbar-logo-text {
  font-family: 'Inter', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
}

.toolbar-search {
  flex: 1;
  max-width: 300px;
  position: relative;
  margin-left: 20px;
}

.toolbar-search input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 36px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition-normal);
}

.toolbar-search input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.toolbar-search input:focus {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.toolbar-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  pointer-events: none;
}

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

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-normal);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--green-600);
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.25);
}

.btn-primary:hover {
  background: var(--green-700);
  box-shadow: 0 4px 12px rgba(45, 106, 79, 0.3);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px;
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* Toolbar button variants */
.btn-toolbar {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.btn-toolbar:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.btn-toolbar-primary {
  background: rgba(255, 255, 255, 0.95);
  color: var(--green-800);
  border: none;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
}

.btn-toolbar-primary:hover {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Toolbar Dropdown */
.toolbar-dropdown {
  position: relative;
}

.toolbar-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: none;
  animation: contextMenuIn 150ms ease-out;
}

.toolbar-dropdown-menu.visible {
  display: block;
}

.toolbar-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
}

.toolbar-dropdown-item:hover {
  background: var(--green-50);
  color: var(--green-800);
}

.toolbar-dropdown-item .icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.toolbar-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

.btn-danger {
  background: rgba(192, 57, 43, 0.08);
  color: var(--danger);
  border: 1px solid rgba(192, 57, 43, 0.15);
}

.btn-danger:hover {
  background: rgba(192, 57, 43, 0.14);
  border-color: rgba(192, 57, 43, 0.3);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

/* ============================================
   Stats Bar (below toolbar)
   ============================================ */
.stats-bar {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  height: 40px;
  z-index: 90;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

#stats-content {
  display: flex;
  align-items: center;
  gap: 24px;
}

.stats-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.stats-item .icon {
  font-size: 0.9rem;
}

.stats-item strong,
.stats-value {
  color: var(--green-800);
  font-weight: 700;
}

/* ============================================
   Tree Container
   ============================================ */
.tree-viewport {
  position: fixed;
  top: 96px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  cursor: grab;
  z-index: var(--z-tree);
  background: var(--bg-primary);
}

.tree-viewport:active {
  cursor: grabbing;
}

.tree-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
}

/* SVG Connections */
.tree-connections {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: var(--z-connections);
}

.connection-line {
  fill: none;
  stroke: var(--green-300);
  stroke-width: 2;
  stroke-linecap: round;
}

.connection-line.spouse {
  stroke: var(--female-border);
  stroke-dasharray: 6 4;
}

.connection-line.highlight {
  stroke: var(--green-600);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 3px rgba(45, 106, 79, 0.3));
}

.spouse-heart {
  fill: var(--female);
  font-size: 12px;
}

/* ============================================
   Family Member Cards
   ============================================ */
.tree-nodes {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-nodes);
}

.member-card {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  padding: 12px;
  gap: 12px;
  overflow: visible;
  box-shadow: var(--shadow-sm);
}

.member-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  transition: var(--transition-normal);
}

.member-card.male::before {
  background: var(--male);
}

.member-card.female::before {
  background: var(--female);
}

.member-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.member-card.male:hover {
  border-color: var(--male-border);
  box-shadow: var(--shadow-md), 0 0 0 3px var(--male-bg);
}

.member-card.female:hover {
  border-color: var(--female-border);
  box-shadow: var(--shadow-md), 0 0 0 3px var(--female-bg);
}

.member-card.selected {
  border-color: var(--green-600);
  box-shadow: var(--shadow-md), 0 0 0 3px var(--green-100);
}

.member-card.highlight {
  animation: cardPulse 1.5s ease-in-out;
}

@keyframes cardPulse {
  0%, 100% { box-shadow: var(--shadow-md); }
  50% { box-shadow: var(--shadow-lg), 0 0 0 4px var(--green-100); }
}

.member-card.deceased {
  opacity: 0.65;
}

.member-card.deceased::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.3);
  pointer-events: none;
  border-radius: var(--radius-lg);
}

/* Avatar */
.member-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  position: relative;
  overflow: hidden;
  border: 2px solid transparent;
  transition: var(--transition-normal);
}

.member-card.male .member-avatar {
  background: var(--male-bg);
  border-color: var(--male-border);
  color: var(--male);
}

.member-card.female .member-avatar {
  background: var(--female-bg);
  border-color: var(--female-border);
  color: var(--female);
}

.member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Card Info */
.member-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.member-name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.member-dates {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-relation {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

.member-actions-hint {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 0.65rem;
  color: var(--text-tertiary);
  opacity: 0;
  transition: var(--transition-normal);
}

.member-card:hover .member-actions-hint {
  opacity: 1;
}

/* ============================================
   Context Menu
   ============================================ */
.context-menu {
  position: fixed;
  z-index: var(--z-context-menu);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px;
  min-width: 190px;
  box-shadow: var(--shadow-lg);
  animation: contextMenuIn 150ms ease-out;
  display: none;
}

.context-menu.visible {
  display: block;
}

@keyframes contextMenuIn {
  from { opacity: 0; transform: scale(0.96) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.context-menu-item:hover {
  background: var(--green-50);
  color: var(--green-800);
}

.context-menu-item .icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.context-menu-item.danger {
  color: var(--danger);
}

.context-menu-item.danger:hover {
  background: rgba(192, 57, 43, 0.06);
}

.context-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

/* ============================================
   Modal
   ============================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-backdrop);
  background: rgba(30, 51, 34, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 200ms ease-out;
}

.modal-backdrop.visible {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green-900);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 1.2rem;
  transition: var(--transition-fast);
}

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

.modal-body {
  padding: 20px 24px;
}

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

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input,
.form-select {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-normal);
  -webkit-appearance: none;
  appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a9f8e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.15);
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Photo Upload */
.photo-upload {
  display: flex;
  align-items: center;
  gap: 16px;
}

.photo-upload-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: var(--transition-normal);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

.photo-upload-preview:hover {
  border-color: var(--green-600);
  color: var(--green-600);
}

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

.photo-upload-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.photo-upload-hint {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.form-section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.form-section-divider::before,
.form-section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.form-input-group {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.form-input-group .form-input {
  flex: 1;
}

.form-input-group .btn {
  flex-shrink: 0;
  white-space: nowrap;
  height: 38px;
}

.form-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.form-hint.success {
  color: var(--success);
}

.form-hint.error {
  color: var(--danger);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  position: fixed;
  top: 96px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: var(--z-tree);
  padding: 20px;
  background: var(--bg-primary);
}

.empty-state.hidden {
  display: none;
}

.empty-state-icon {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--green-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.empty-state-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
}

.empty-state-desc {
  color: var(--text-secondary);
  text-align: center;
  max-width: 380px;
  line-height: 1.6;
  font-size: 0.92rem;
}

.empty-state .btn {
  font-size: 0.95rem;
  padding: 11px 28px;
  border-radius: var(--radius-full);
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 0.85rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 300ms ease-out;
  max-width: 320px;
}

.toast.removing {
  animation: toastOut 200ms ease-in forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* ============================================
   Zoom Controls (bottom-left)
   ============================================ */
.zoom-controls {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: var(--z-toolbar);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  box-shadow: var(--shadow-md);
}

.zoom-controls .btn-ghost {
  width: 34px;
  height: 34px;
  font-size: 1.1rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.zoom-controls .btn-ghost:hover {
  background: var(--green-50);
  color: var(--green-800);
}

.zoom-level {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  text-align: center;
  padding: 2px 0;
  user-select: none;
  font-weight: 600;
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ============================================
   Confirm Modal
   ============================================ */
.confirm-modal .modal {
  max-width: 380px;
}

.confirm-message {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  text-align: center;
  padding: 8px 0;
}

.confirm-icon {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 8px;
}

/* ============================================
   Search Results Dropdown
   ============================================ */
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 260px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 10;
}

.search-results.visible {
  display: block;
  animation: contextMenuIn 150ms ease-out;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: var(--text-primary);
}

.search-result-item:hover {
  background: var(--green-50);
}

.search-result-item .avatar-mini {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.search-result-item .avatar-mini.male {
  background: var(--male-bg);
  color: var(--male);
}

.search-result-item .avatar-mini.female {
  background: var(--female-bg);
  color: var(--female);
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.search-result-dates {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.search-no-results {
  padding: 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

/* ============================================
   Node Entrance Animation
   ============================================ */
.member-card.entering {
  animation: nodeEnter 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes nodeEnter {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

.connection-line.entering {
  animation: lineEnter 600ms ease-out forwards;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
}

@keyframes lineEnter {
  to { stroke-dashoffset: 0; }
}

/* ============================================
   Responsive
   ============================================ */
.mobile-search-close {
  display: none;
}

@media (max-width: 768px) {
  .toolbar {
    padding: 6px 8px;
    gap: 6px;
    height: auto;
    min-height: 44px;
  }

  .toolbar-logo-text {
    display: none;
  }

  /* Search - collapse to icon, expand as overlay */
  .toolbar-search {
    max-width: 44px;
    min-width: 44px;
    margin-left: 0;
    cursor: pointer;
    overflow: hidden;
    transition: none;
  }

  .toolbar-search input {
    opacity: 0;
    width: 0;
    padding: 0;
    cursor: pointer;
  }

  .toolbar-search.mobile-search-open {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: 100%;
    min-width: 100%;
    z-index: 300;
    background: rgba(255,255,255,0.97);
    padding: 16px;
    padding-top: 20px;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-search.mobile-search-open input {
    opacity: 1;
    width: 100%;
    padding: 12px 16px;
    font-size: 1.1rem;
    border: 2px solid var(--green-500);
    border-radius: var(--radius-md);
    background: white;
  }

  .toolbar-search.mobile-search-open .search-icon {
    position: absolute;
    top: 28px;
    left: 24px;
    font-size: 1.2rem;
  }

  .toolbar-search.mobile-search-open input {
    padding-left: 44px;
  }

  .toolbar-search.mobile-search-open .search-results {
    position: relative;
    top: 0;
    max-height: calc(100vh - 120px);
    margin-top: 8px;
    box-shadow: none;
    border: 1px solid var(--border);
  }

  .mobile-search-close {
    display: none;
  }

  .toolbar-search.mobile-search-open .mobile-search-close {
    display: flex;
    position: absolute;
    top: 20px;
    right: 16px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-secondary);
    z-index: 301;
  }

  .toolbar-actions {
    gap: 2px;
  }

  .toolbar-actions .btn-text {
    display: none;
  }

  .toolbar-separator {
    display: none;
  }
  
  .btn-toolbar, .btn-toolbar-primary {
    padding: 6px 8px;
    font-size: 0.85rem;
  }

  .empty-state-title {
    font-size: 1.4rem;
  }

  .empty-state-desc {
    font-size: 0.85rem;
  }

  /* Stats bar - compact on mobile */
  .stats-bar {
    gap: 8px;
    padding: 4px 8px;
    font-size: 0.7rem;
    min-height: 28px;
  }

  .stats-item {
    gap: 2px;
  }

  .modal {
    width: 95%;
    max-height: 90vh;
  }

  /* Filter bar - bottom sheet on mobile */
  .filter-bar {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    z-index: 200;
    border-top: 1px solid var(--border);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    padding: 16px;
    max-height: 50vh;
    overflow-y: auto;
    transform: translateY(110%);
    transition: transform 0.3s ease, visibility 0.3s;
    visibility: hidden;
  }

  .filter-bar.mobile-open {
    transform: translateY(0);
    visibility: visible;
  }

  .filter-bar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .filter-label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 4px;
  }

  .filter-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .filter-group-label {
    font-size: 0.72rem;
  }

  .filter-chips {
    flex-wrap: wrap;
    gap: 6px;
  }

  .filter-chip {
    font-size: 0.78rem;
    padding: 5px 12px;
  }

  #btn-clear-filter {
    align-self: center;
    margin-top: 4px;
  }

  /* Filter toggle button badge */
  .filter-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent);
    color: white;
    font-size: 0.6rem;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
  }

  /* Filter overlay backdrop */
  .filter-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
  }

  .filter-overlay.visible {
    opacity: 1;
    pointer-events: all;
  }

  /* Detail panel full-width on mobile */
  .detail-panel {
    max-width: 100%;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .toolbar-search {
    max-width: 110px;
    min-width: 60px;
  }

  :root {
    --card-width: 155px;
    --card-height: 76px;
    --spouse-gap: 20px;
    --sibling-gap: 24px;
    --generation-gap: 90px;
  }

  .member-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
  }

  .member-name {
    font-size: 0.75rem;
  }

  .member-dates {
    font-size: 0.65rem;
  }
  
  .member-role {
    font-size: 0.6rem;
  }

  .login-card {
    margin: 10px;
    padding: 24px 20px;
  }

  .stats-bar {
    font-size: 0.65rem;
    gap: 6px;
    padding: 3px 6px;
  }
}

/* ============================================
   Admin login toggle
   ============================================ */
.login-admin-toggle {
  font-size: 0.85rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.login-admin-toggle:hover {
  opacity: 1;
}

.admin-login-section {
  margin-top: 8px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Filter toggle button */
#btn-toggle-filter {
  position: relative;
}

/* Mobile: fix dropdown clipping */
@media (max-width: 768px) {
  .toolbar-dropdown-menu {
    position: fixed;
    top: auto;
    right: 8px;
    left: 8px;
    max-height: 60vh;
    overflow-y: auto;
  }
  
  .tree-selector-menu {
    min-width: auto;
    width: calc(100vw - 16px);
  }
}

/* ============================================
   Member Detail Panel
   ============================================ */
.detail-panel {
  max-width: 420px;
}

.detail-header-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.detail-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.detail-avatar.male {
  background: var(--male-bg);
  border: 3px solid var(--male-border);
  color: var(--male);
}

.detail-avatar.female {
  background: var(--female-bg);
  border: 3px solid var(--female-border);
  color: var(--female);
}

.detail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.detail-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.detail-subtitle {
  font-size: 0.82rem;
  color: var(--text-tertiary);
  margin-top: 2px;
  font-style: italic;
}

.detail-gender-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 6px;
}

.detail-gender-tag.male {
  background: var(--male-bg);
  color: var(--male);
}

.detail-gender-tag.female {
  background: var(--female-bg);
  color: var(--female);
}

.detail-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-info-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-info-value {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
}

.detail-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--green-800);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.detail-family-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.detail-family-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.detail-family-item:hover {
  background: var(--green-50);
}

.detail-family-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.detail-family-avatar.male {
  background: var(--male-bg);
  color: var(--male);
  border: 2px solid var(--male-border);
}

.detail-family-avatar.female {
  background: var(--female-bg);
  color: var(--female);
  border: 2px solid var(--female-border);
}

.detail-family-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
}

.detail-family-relation {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-left: auto;
  flex-shrink: 0;
}

.detail-notes {
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  border-left: 3px solid var(--green-400);
}

.detail-nickname {
  font-size: 0.82rem;
  color: var(--green-700);
  font-style: italic;
  margin-top: 2px;
}

.detail-contact-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: var(--transition-fast);
  cursor: pointer;
}

.detail-contact-item:hover {
  background: var(--green-50);
  color: var(--green-800);
}

.detail-contact-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* ============================================
   Birthday Feature
   ============================================ */

.birthday-btn {
  position: relative;
}

.birthday-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e63946;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.birthday-panel .modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

.birthday-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
}

.birthday-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  border-left: 3px solid transparent;
}

.birthday-item:hover {
  background: var(--surface-hover);
}

.birthday-item.urgent {
  border-left-color: #e63946;
  background: #fff5f5;
}

.birthday-item.soon {
  border-left-color: #f4a261;
  background: #fffbf5;
}

.birthday-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.birthday-avatar.male {
  background: var(--green-100);
  color: var(--green-800);
}

.birthday-avatar.female {
  background: #fce4ec;
  color: #c62828;
}

.birthday-info {
  flex: 1;
  min-width: 0;
}

.birthday-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.birthday-date {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.birthday-countdown {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--green-100);
  color: var(--green-800);
  white-space: nowrap;
}

.birthday-countdown.urgent {
  background: #fde2e4;
  color: #e63946;
}

.birthday-countdown.soon {
  background: #fef3e2;
  color: #e76f51;
}

/* Birthday badge on member card */
.member-card .birthday-indicator {
  position: absolute;
  top: -12px;
  right: -12px;
  font-size: 1.4rem;
  z-index: 10;
  background: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  animation: badge-pulse 2s ease-in-out infinite;
}

/* ============================================
   Tree Selector
   ============================================ */

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.dropdown-arrow {
  font-size: 0.7rem;
  opacity: 0.6;
}

.tree-selector-menu {
  min-width: 240px;
}

.tree-selector-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px;
}

.tree-selector-item.active {
  background: var(--green-50);
}

.tree-select-btn {
  flex: 1;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.tree-select-btn:hover {
  background: var(--surface-hover);
}

.tree-item-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.tree-selector-item:hover .tree-item-actions {
  opacity: 1;
}

.tree-action-btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  transition: var(--transition-fast);
}

.tree-action-btn:hover {
  background: var(--surface-active);
}

/* ============================================
   Filter Bar
   ============================================ */

.filter-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  z-index: 89;
  position: relative;
}

.filter-bar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-group-label {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  white-space: nowrap;
}

.filter-chips {
  display: flex;
  gap: 4px;
}

.filter-chip {
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition-fast);
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--green-400);
  color: var(--green-700);
}

.filter-chip.active {
  background: var(--green-800);
  color: white;
  border-color: var(--green-800);
}

/* Filter dimmed state */
.member-card.filter-dimmed {
  opacity: 0.15;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.connection-dimmed {
  opacity: 0.1;
  transition: opacity 0.3s ease;
}

/* Path highlight state */
.member-card.path-highlighted {
  box-shadow: 0 0 0 3px var(--green-500), 0 0 16px rgba(82, 183, 136, 0.4);
  transform: scale(1.02);
  z-index: 5;
}

.connection-highlighted {
  stroke: var(--green-500) !important;
  stroke-width: 3 !important;
  opacity: 1;
}

/* ============================================
   In-law Visual Distinction
   ============================================ */

.member-card.in-law {
  border-style: dashed;
  border-color: var(--border-hover);
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-tertiary) 100%);
}

.in-law-badge {
  position: absolute;
  top: -12px;
  left: -12px;
  font-size: 1.4rem;
  z-index: 10;
  background: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  line-height: 1;
}

.member-card.in-law .member-name {
  font-style: italic;
}

/* ============================================
   Highlight Exit Banner
   ============================================ */

.highlight-exit-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green-900);
  color: white;
  padding: 10px 20px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  font-size: 0.85rem;
  animation: banner-slide-up 0.3s ease-out;
  backdrop-filter: blur(10px);
}

@keyframes banner-slide-up {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.highlight-exit-btn {
  background: rgba(255, 255, 255, 0.2) !important;
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  padding: 5px 14px !important;
  border-radius: 8px !important;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.highlight-exit-btn:hover {
  background: rgba(255, 255, 255, 0.35) !important;
}

/* ============================================
   Login Screen
   ============================================ */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: linear-gradient(135deg, var(--green-50) 0%, var(--bg-primary) 40%, #f0f5f0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  border: 1px solid var(--border);
}

.login-logo {
  font-size: 4rem;
  margin-bottom: 8px;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--green-900);
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-normal);
}

.btn-google:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.login-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  gap: 12px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-divider span {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-hint {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 12px;
}

.login-error {
  margin-top: 12px;
  padding: 10px;
  background: rgba(192, 57, 43, 0.08);
  border: 1px solid rgba(192, 57, 43, 0.15);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.82rem;
}

/* ============================================
   User Avatar (toolbar)
   ============================================ */
.user-avatar-btn {
  display: flex !important;
  align-items: center;
  gap: 8px;
  width: auto !important;
  padding: 4px 10px !important;
}

.user-avatar-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
}

.user-info-item {
  pointer-events: none;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary) !important;
}

/* ============================================
   Share Modal
   ============================================ */
.share-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.share-tab {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition-fast);
}

.share-tab:hover {
  color: var(--green-700);
}

.share-tab.active {
  color: var(--green-800);
  border-bottom-color: var(--green-600);
  font-weight: 600;
}

.share-tab-content {
  display: none;
}

.share-tab-content.active {
  display: block;
}

/* Permission member items */
.perm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  margin-bottom: 8px;
}

.perm-item .perm-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.perm-info {
  flex: 1;
  min-width: 0;
}

.perm-name {
  font-weight: 600;
  font-size: 0.85rem;
}

.perm-detail {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.perm-role {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.perm-role.admin {
  background: rgba(45, 106, 79, 0.1);
  color: var(--green-700);
}

.perm-role.editor {
  background: rgba(199, 140, 30, 0.1);
  color: var(--warning);
}

.perm-role.viewer {
  background: rgba(138, 159, 142, 0.1);
  color: var(--text-secondary);
}

/* Invite link items */
.invite-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  margin-bottom: 8px;
  font-size: 0.82rem;
}

.invite-item .invite-code {
  font-family: monospace;
  font-weight: 600;
  color: var(--green-800);
}

.invite-item .invite-info {
  flex: 1;
  min-width: 0;
}

.invite-item .invite-usage {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* Permission-aware card styling */
.member-card.read-only {
  opacity: 0.85;
}

.member-card.read-only .member-actions-hint {
  display: none;
}
