/* ============================================================================
   Ferguson Family Archive - Prototype Styles
   Design System & Component Library
   ============================================================================ */

/* CSS Variables / Design Tokens */
:root {
  /* Primary colors */
  --color-primary: #3b82f6;
  --color-secondary: #f59e0b;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;

  /* Neutrals */
  --color-bg: #ffffff;
  --color-bg-secondary: #f3f4f6;
  --color-bg-tertiary: #e5e7eb;
  --color-border: #e5e7eb;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --color-text-lighter: #9ca3af;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);

  /* Border radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Typography */
  --font-xs: 0.75rem;
  --font-sm: 0.875rem;
  --font-base: 1rem;
  --font-lg: 1.125rem;
  --font-xl: 1.25rem;
  --font-2xl: 1.5rem;
  --font-3xl: 1.875rem;
  --font-4xl: 2.25rem;

  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Layout */
  --nav-height: 60px;
  --side-nav-width: 220px;
}

/* ============================================================================
   Base Styles & Reset
   ============================================================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: var(--font-base);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg-secondary);
  overflow-x: hidden;
}

html, body {
  height: 100%;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: #2563eb;
}

/* ============================================================================
   Top Navigation
   ============================================================================ */

.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: white;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.nav-logo {
  font-size: var(--font-2xl);
  cursor: pointer;
  transition: transform 0.2s;
}

.nav-logo:hover {
  transform: scale(1.1);
}

.nav-title {
  font-size: var(--font-lg);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  margin: 0;
}

.nav-center {
  flex: 1;
  max-width: 500px;
  margin: 0 var(--space-xl);
}

.nav-search {
  width: 100%;
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  transition: all 0.2s;
}

.nav-search:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.nav-right {
  position: relative;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
}

.user-menu:hover {
  background: var(--color-bg-secondary);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-semibold);
  font-size: var(--font-sm);
}

.user-name {
  font-size: var(--font-sm);
  font-weight: var(--font-medium);
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--space-sm);
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: var(--space-sm);
  display: none;
  z-index: 200;
}

.user-dropdown.active {
  display: block;
}

.user-dropdown a {
  display: block;
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.user-dropdown a:hover {
  background: var(--color-bg-secondary);
}

.user-dropdown hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-sm) 0;
}

/* ============================================================================
   Side Navigation
   ============================================================================ */

.side-nav {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  width: var(--side-nav-width);
  height: calc(100vh - var(--nav-height));
  background: white;
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  z-index: 90;
  transition: transform 0.3s;
}

.side-menu {
  padding: var(--space-md);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  color: var(--color-text);
  border-radius: var(--radius-md);
  transition: all 0.2s;
  margin-bottom: var(--space-xs);
}

.menu-item:hover {
  background: var(--color-bg-secondary);
}

.menu-item.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-primary);
  font-weight: var(--font-medium);
}

.menu-icon {
  font-size: var(--font-xl);
}

.menu-label {
  font-size: var(--font-base);
}

/* ============================================================================
   Main Content
   ============================================================================ */

.main-content {
  margin-top: var(--nav-height);
  margin-left: var(--side-nav-width);
  min-height: calc(100vh - var(--nav-height));
  padding: var(--space-xl);
}

.view {
  display: none;
  animation: fadeIn 0.3s;
}

.view.active {
  display: block;
}

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

/* ============================================================================
   View Header
   ============================================================================ */

.view-header {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.view-header h2 {
  flex: 1;
  font-size: var(--font-2xl);
  font-weight: var(--font-bold);
}

.view-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* ============================================================================
   Dashboard
   ============================================================================ */

.hero-section {
  text-align: center;
  padding: var(--space-2xl) 0;
  margin-bottom: var(--space-xl);
}

.hero-title {
  font-size: var(--font-4xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.hero-stats {
  font-size: var(--font-xl);
  color: var(--color-text-light);
}

.hero-version {
  margin-top: var(--space-md);
  font-size: var(--font-sm);
  color: var(--color-text-light);
  opacity: 0.6;
  font-weight: var(--font-medium);
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.icon-card {
  background: white;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.icon-card-icon {
  font-size: 4rem;
  margin-bottom: var(--space-md);
}

.icon-card h3 {
  font-size: var(--font-xl);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-sm);
  color: var(--color-text);
}

.icon-card p {
  color: var(--color-text-light);
  font-size: var(--font-sm);
}

.recent-activity {
  background: white;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.recent-activity h2 {
  font-size: var(--font-xl);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-lg);
}

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.activity-item {
  display: flex;
  align-items: start;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  transition: background 0.2s;
}

.activity-item:hover {
  background: var(--color-bg-secondary);
}

.activity-icon {
  font-size: var(--font-xl);
}

.activity-content p {
  margin-bottom: var(--space-xs);
}

.activity-time {
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

/* ============================================================================
   Family Tree - Modern Full-Width Design with Floating Navigation
   ============================================================================ */

/* Simple Header */
.tree-header-simple {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: white;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.tree-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.btn-back-minimal {
  background: none;
  border: none;
  font-size: var(--font-2xl);
  color: var(--color-text-light);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.btn-back-minimal:hover {
  background: var(--color-bg-secondary);
  color: var(--color-primary);
}

.tree-title {
  font-size: var(--font-xl);
  font-weight: var(--font-bold);
  margin: 0;
  color: var(--color-text);
}

.tree-stats {
  font-size: var(--font-sm);
  color: var(--color-text-light);
  padding: var(--space-xs) var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-full);
}

.tree-header-right {
  display: flex;
  gap: var(--space-sm);
}

.btn-icon-modern {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-lg);
  cursor: pointer;
  transition: all 0.2s;
  min-width: 40px;
  min-height: 40px;
}

.btn-icon-modern:hover {
  background: #2563eb;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Floating Navigation Panel */
.tree-nav-panel {
  position: fixed;
  top: calc(var(--nav-height) + 80px);
  right: var(--space-lg);
  width: 300px;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 50;
  transition: all 0.3s ease;
}

.tree-nav-toggle {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: var(--color-bg-secondary);
  border: none;
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-lg);
  transition: all 0.2s;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-nav-toggle:hover {
  background: var(--color-primary);
  color: white;
}

.tree-nav-content {
  padding: var(--space-xl);
  padding-top: 3.5rem;
  max-height: 70vh;
  overflow-y: auto;
}

.tree-nav-content::-webkit-scrollbar {
  width: 6px;
}

.tree-nav-content::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

/* Quick Search */
.tree-search-box {
  position: relative;
  margin-bottom: var(--space-lg);
}

.tree-search-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  padding-right: 2.5rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  transition: all 0.2s;
}

.tree-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.tree-search-icon {
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-lighter);
}

/* Breadcrumb Trail */
.tree-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  padding: var(--space-sm);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
}

.breadcrumb-item {
  background: none;
  border: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-xs);
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.breadcrumb-item:hover {
  background: white;
  color: var(--color-primary);
}

/* Control Labels */
.tree-control-label {
  display: block;
  font-size: var(--font-xs);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
  margin-top: var(--space-lg);
}

.tree-control-label:first-of-type {
  margin-top: 0;
}

/* Zoom Controls */
.tree-zoom-controls {
  margin-bottom: var(--space-md);
}

.zoom-btn-group {
  display: flex;
  gap: var(--space-xs);
}

.zoom-btn-group button {
  flex: 1;
  padding: var(--space-sm);
  background: white;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: all 0.2s;
}

.zoom-btn-group button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(59, 130, 246, 0.05);
}

.zoom-btn-group button:active {
  transform: scale(0.95);
}

/* Filter Chips */
.tree-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.tree-filter-chip {
  padding: var(--space-sm) var(--space-md);
  background: white;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.tree-filter-chip:hover {
  border-color: var(--color-primary);
  background: rgba(59, 130, 246, 0.05);
}

.tree-filter-chip[data-active="true"] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

/* View Options */
.tree-view-options {
  margin-bottom: var(--space-md);
}

.view-btn-group {
  display: flex;
  gap: var(--space-xs);
}

.view-btn-group button {
  flex: 1;
  padding: var(--space-sm);
  background: white;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-xs);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: all 0.2s;
}

.view-btn-group button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(59, 130, 246, 0.05);
}

/* Mini-Map */
.tree-minimap {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  height: 120px;
  position: relative;
  margin-top: var(--space-lg);
  border: 2px solid var(--color-border);
}

.minimap-viewport {
  position: absolute;
  border: 2px solid var(--color-primary);
  background: rgba(59, 130, 246, 0.1);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

/* Full-Width Tree Canvas */
.tree-canvas-fullwidth {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  height: calc(100vh - var(--nav-height) - 160px);
  overflow: auto;
  position: relative;
  padding: var(--space-xl);
  scroll-behavior: smooth;
  /* HIDDEN BY DEFAULT - Will be improved later */
  display: none !important;
}

.tree-canvas-fullwidth:focus {
  outline: 3px solid var(--color-primary);
  outline-offset: -3px;
}

.tree-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--color-text-light);
  font-size: var(--font-lg);
  gap: var(--space-md);
}

/* Quick Info Tooltip */
.tree-quick-info {
  position: fixed;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: var(--space-md);
  max-width: 300px;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.2s;
}

.tree-quick-info[aria-hidden="false"] {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   NEW MOBILE-FIRST ORGANIZATION CHART STYLES
   ============================================================ */

.tree-controls {
  display: flex;
  gap: 8px;
  padding: 16px;
  background: white;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.tree-control-btn {
  padding: 8px 16px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tree-control-btn:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}

.tree-control-btn:active {
  transform: translateY(0);
}

.tree-scroll-container {
  overflow: auto;
  height: calc(100vh - 200px);
  background: var(--color-bg-secondary);
  padding: 24px;
}

.tree-org-chart {
  display: flex;
  flex-direction: column;
  gap: 32px;
  min-width: min-content;
  transform-origin: top left;
  transition: transform 0.3s ease;
}

.tree-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.tree-couple {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.tree-spouse-connector {
  font-size: 24px;
  padding: 0 8px;
}

.tree-person-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  min-width: 200px;
  max-width: 280px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.2s;
  border-left-width: 4px;
  border-left-style: solid;
}

.tree-person-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}

.tree-person-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
  line-height: 1.3;
}

.tree-person-dates {
  font-size: 14px;
  color: var(--color-text-light);
  margin-bottom: 12px;
}

.tree-person-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.tree-person-btn {
  padding: 6px 12px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tree-person-btn:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.tree-toggle-btn {
  padding: 10px 20px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin: 8px 0;
}

.tree-toggle-btn:hover {
  background: var(--color-primary-dark);
  transform: scale(1.05);
}

.tree-children {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 32px;
  padding: 32px 0;
  margin-top: 24px;
  position: relative;
}

/* Mobile & Tablet Responsive Design */
@media (max-width: 1024px) {
  .tree-nav-panel {
    width: 280px;
    top: calc(var(--nav-height) + 70px);
  }

  .person-panel-enhanced {
    width: 400px;
  }
}

@media (max-width: 768px) {
  /* Stack header elements on small screens */
  .tree-header-simple {
    flex-direction: column;
    gap: var(--space-md);
    align-items: flex-start;
  }

  .tree-header-left {
    width: 100%;
  }

  .tree-header-right {
    width: 100%;
    justify-content: flex-end;
  }

  /* Full-width person panel on mobile */
  .person-panel-enhanced {
    width: 100%;
    right: -100%;
  }

  .tree-canvas-fullwidth {
    height: calc(100vh - var(--nav-height) - 140px);
  }

  /* Adjust tree controls for mobile */
  .tree-controls {
    justify-content: center;
    gap: 6px;
    padding: 12px;
  }

  .tree-control-btn {
    padding: 10px 14px;
    font-size: 13px;
    flex: 1;
    min-width: 70px;
  }

  .tree-scroll-container {
    padding: 16px;
    height: calc(100vh - 180px);
  }

  .tree-org-chart {
    gap: 24px;
  }

  .tree-couple {
    flex-direction: column;
    gap: 12px;
  }

  .tree-person-card {
    min-width: 100%;
    max-width: 100%;
    padding: 16px;
  }

  .tree-person-name {
    font-size: 16px;
  }

  .tree-person-dates {
    font-size: 13px;
  }

  .tree-person-btn {
    flex: 1;
    text-align: center;
  }

  .tree-children {
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    margin-left: 10px;
  }

  .tree-toggle-btn {
    width: 100%;
    padding: 12px;
  }

  .tree-spouse-connector {
    font-size: 20px;
    transform: rotate(90deg);
  }

  /* Mobile-friendly filter chips */
  .tree-filter-chip {
    font-size: var(--font-xs);
    padding: var(--space-xs) var(--space-sm);
  }

  /* Hide minimap on mobile */
  .tree-minimap {
    display: none;
  }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 480px) {
  .tree-person-card {
    padding: 14px;
  }

  .tree-person-name {
    font-size: 15px;
  }

  .tree-person-dates {
    font-size: 12px;
  }

  .tree-person-actions {
    flex-direction: column;
  }

  .tree-person-btn {
    width: 100%;
  }

  .btn-icon-modern {
    min-width: 36px;
    min-height: 36px;
    padding: var(--space-xs) var(--space-sm);
  }

  .tree-stats {
    font-size: var(--font-xs);
  }
}

/* Enhanced Person Detail Panel */
.person-panel-enhanced {
  position: fixed;
  top: var(--nav-height);
  right: -450px;
  width: 450px;
  height: calc(100vh - var(--nav-height));
  background: white;
  box-shadow: var(--shadow-xl);
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 95;
  display: flex;
  flex-direction: column;
}

.person-panel-enhanced.active {
  right: 0;
}

.person-panel-header {
  padding: var(--space-lg);
  border-bottom: 2px solid var(--color-border);
  background: var(--color-bg-secondary);
  position: relative;
}

.person-panel-header h3 {
  margin: 0;
  font-size: var(--font-xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
  padding-right: 3rem;
}

.btn-close-enhanced {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 40px;
  height: 40px;
  border: none;
  background: white;
  border-radius: var(--radius-full);
  font-size: var(--font-2xl);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
  box-shadow: var(--shadow-sm);
}

.btn-close-enhanced:hover {
  background: var(--color-danger);
  color: white;
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

.person-panel-content {
  flex: 1;
  padding: var(--space-xl);
  overflow-y: auto;
}

.btn-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 36px;
  height: 36px;
  border: none;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-full);
  font-size: var(--font-2xl);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
}

.btn-close:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

/* ============================================================================
   Media Browser
   ============================================================================ */

.search-bar {
  flex: 1;
}

.search-bar input {
  width: 100%;
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-base);
}

.view-switcher {
  display: flex;
  gap: var(--space-xs);
  background: var(--color-bg-secondary);
  padding: var(--space-xs);
  border-radius: var(--radius-md);
}

.btn-view {
  padding: var(--space-sm) var(--space-md);
  border: none;
  background: transparent;
  color: var(--color-text-light);
  font-size: var(--font-sm);
  font-weight: var(--font-medium);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.media-layout {
  display: flex;
  gap: var(--space-lg);
}

.media-filters {
  width: 280px;
  background: white;
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  height: fit-content;
}

.media-filters h3 {
  font-size: var(--font-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-lg);
}

.filter-section {
  margin-bottom: var(--space-xl);
}

.filter-section label {
  display: block;
  font-size: var(--font-sm);
  font-weight: var(--font-medium);
  margin-bottom: var(--space-sm);
  color: var(--color-text);
}

.slider {
  width: 100%;
  margin: var(--space-md) 0;
}

.slider-values {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.media-content {
  flex: 1;
}

.media-count {
  font-size: var(--font-base);
  color: var(--color-text-light);
  margin-bottom: var(--space-lg);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-lg);
}

.media-card {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.media-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.media-card-image {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

.media-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 60px;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  opacity: 0;
  transition: opacity 0.2s;
}

.media-card:hover .media-card-overlay {
  opacity: 1;
}

.media-card-action {
  color: white;
  font-size: var(--font-sm);
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  transition: background 0.2s;
}

.media-card-action:hover {
  background: rgba(255, 255, 255, 0.3);
}

.media-card-info {
  padding: var(--space-md);
}

.media-card-title {
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-xs);
  color: var(--color-text);
  font-size: var(--font-sm);
}

.media-card-meta {
  font-size: var(--font-xs);
  color: var(--color-text-light);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* ============================================================================
   Lightbox Modal
   ============================================================================ */

.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
}

.lightbox.active {
  display: block;
}

.lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
}

.lightbox-content {
  position: relative;
  width: 90%;
  max-width: 1400px;
  height: 90vh;
  margin: 5vh auto;
  background: white;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}

.lightbox-header {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}

.lightbox-header h3 {
  flex: 1;
  font-size: var(--font-xl);
  font-weight: var(--font-semibold);
}

.lightbox-nav-btn {
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--color-border);
  background: white;
  border-radius: var(--radius-md);
  font-size: var(--font-base);
  cursor: pointer;
  transition: all 0.2s;
}

.lightbox-nav-btn:hover {
  background: var(--color-bg-secondary);
}

.lightbox-close {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-full);
  font-size: var(--font-2xl);
  cursor: pointer;
  transition: all 0.2s;
}

.lightbox-close:hover {
  background: var(--color-bg-tertiary);
}

.lightbox-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.lightbox-image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  background: var(--color-bg-secondary);
}

.lightbox-image-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.lightbox-sidebar {
  width: 400px;
  padding: var(--space-xl);
  overflow-y: auto;
  border-left: 1px solid var(--color-border);
}

.lightbox-section {
  margin-bottom: var(--space-xl);
}

.lightbox-section h4 {
  font-size: var(--font-base);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-md);
}

.lightbox-description {
  font-size: var(--font-sm);
  line-height: 1.6;
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.lightbox-confidence {
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.lightbox-people {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.person-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.person-tag:hover {
  background: var(--color-bg-tertiary);
}

.lightbox-details {
  font-size: var(--font-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.detail-row {
  display: flex;
  gap: var(--space-sm);
}

.detail-label {
  color: var(--color-text-light);
}

.detail-value {
  font-weight: var(--font-medium);
}

/* ============================================================================
   Collections
   ============================================================================ */

.collections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-xl);
}

.collection-card {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all 0.2s;
}

.collection-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.collection-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.collection-card-content {
  padding: var(--space-lg);
}

.collection-card-title {
  font-size: var(--font-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-sm);
}

.collection-card-meta {
  font-size: var(--font-sm);
  color: var(--color-text-light);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* ============================================================================
   Timeline
   ============================================================================ */

.timeline-container {
  background: white;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.timeline-year {
  margin-bottom: var(--space-2xl);
}

.timeline-year-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  cursor: pointer;
}

.timeline-year-header h3 {
  font-size: var(--font-2xl);
  font-weight: var(--font-bold);
  color: var(--color-primary);
}

.timeline-year-stats {
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.timeline-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-md);
  padding-left: var(--space-xl);
}

/* ============================================================================
   Map View
   ============================================================================ */

.map-layout {
  display: flex;
  gap: var(--space-lg);
  height: calc(100vh - var(--nav-height) - 200px);
}

.map-canvas {
  flex: 1;
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.map-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  position: relative;
}

.map-placeholder p {
  font-size: var(--font-xl);
  margin-bottom: var(--space-sm);
}

.map-note {
  font-size: var(--font-sm);
  opacity: 0.8;
}

.map-markers {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.map-marker {
  position: absolute;
  font-size: var(--font-2xl);
  cursor: pointer;
  transition: transform 0.2s;
}

.map-marker:hover {
  transform: scale(1.3);
}

.map-sidebar {
  width: 300px;
  background: white;
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow-y: auto;
}

.map-sidebar h3 {
  font-size: var(--font-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-lg);
}

.location-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.location-item {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.location-item:hover {
  background: var(--color-bg-secondary);
}

.location-item strong {
  font-weight: var(--font-semibold);
}

.location-item span {
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

/* ============================================================================
   Statistics
   ============================================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: white;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.stat-value {
  font-size: var(--font-3xl);
  font-weight: var(--font-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
}

.stat-label {
  font-size: var(--font-base);
  color: var(--color-text-light);
  margin-bottom: var(--space-md);
}

.stat-sublabel {
  font-size: var(--font-sm);
  color: var(--color-text-light);
  margin-top: var(--space-sm);
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-md);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-full);
  transition: width 0.3s;
}

.stats-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.chart-card {
  background: white;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.chart-card h3 {
  font-size: var(--font-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-lg);
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: var(--space-md);
  height: 200px;
}

.bar {
  flex: 1;
  background: var(--color-primary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  position: relative;
  transition: all 0.3s;
  cursor: pointer;
}

.bar:hover {
  opacity: 0.8;
}

.bar-label {
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--font-xs);
  color: var(--color-text-light);
  white-space: nowrap;
}

.insights-card {
  background: white;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.insights-card h3 {
  font-size: var(--font-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-lg);
}

.insights-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.insights-list li {
  padding-left: var(--space-xl);
  position: relative;
  font-size: var(--font-base);
  line-height: 1.6;
}

.insights-list li::before {
  content: "•";
  position: absolute;
  left: var(--space-sm);
  color: var(--color-primary);
  font-size: var(--font-xl);
}

/* ============================================================================
   Upload Interface
   ============================================================================ */

.upload-container {
  max-width: 800px;
  margin: 0 auto;
}

.upload-dropzone {
  background: white;
  border: 3px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-dropzone:hover {
  border-color: var(--color-primary);
  background: rgba(59, 130, 246, 0.02);
}

.dropzone-icon {
  font-size: 4rem;
  margin-bottom: var(--space-lg);
}

.dropzone-content h3 {
  font-size: var(--font-xl);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-lg);
}

.dropzone-help {
  margin-top: var(--space-lg);
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.upload-queue {
  background: white;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  margin-top: var(--space-xl);
  box-shadow: var(--shadow-md);
}

.upload-queue h3 {
  font-size: var(--font-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-lg);
}

.upload-item {
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.upload-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.upload-item-name {
  font-weight: var(--font-medium);
}

.upload-item-size {
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.upload-progress {
  height: 6px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width 0.3s;
}

.upload-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

/* ============================================================================
   AI Review Queue
   ============================================================================ */

.review-counter {
  font-size: var(--font-base);
  color: var(--color-text-light);
}

.review-container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.review-image-container {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  min-height: 500px;
}

.review-image-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.review-details {
  background: white;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.review-section h3 {
  font-size: var(--font-base);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-md);
}

.review-description {
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  line-height: 1.6;
  min-height: 100px;
}

.review-description:focus {
  outline: none;
  border-color: var(--color-primary);
}

.review-confidence {
  font-size: var(--font-sm);
  color: var(--color-text-light);
  margin-top: var(--space-sm);
}

.review-people {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.review-metadata {
  font-size: var(--font-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.review-actions {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
}

/* ============================================================================
   Person Profile
   ============================================================================ */

.profile-container {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-2xl);
}

.profile-header {
  display: flex;
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}

.profile-photo-large {
  width: 150px;
  height: 150px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--font-4xl);
  font-weight: var(--font-bold);
  flex-shrink: 0;
}

.profile-info h1 {
  font-size: var(--font-3xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-sm);
}

.profile-info > div {
  font-size: var(--font-base);
  color: var(--color-text-light);
  margin-bottom: var(--space-xs);
}

.profile-bio {
  font-size: var(--font-base);
  line-height: 1.8;
  color: var(--color-text);
  margin-bottom: var(--space-xl);
}

.profile-tabs {
  display: flex;
  gap: var(--space-sm);
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-xl);
}

.tab-button {
  padding: var(--space-md) var(--space-xl);
  border: none;
  background: transparent;
  font-size: var(--font-base);
  font-weight: var(--font-medium);
  color: var(--color-text-light);
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.tab-button:hover {
  color: var(--color-text);
}

.tab-button.active {
  color: var(--color-primary);
}

.tab-button.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-primary);
}

.profile-tab-content {
  min-height: 300px;
}

/* ============================================================================
   Settings
   ============================================================================ */

.settings-layout {
  display: flex;
  gap: var(--space-xl);
}

.settings-sidebar {
  width: 200px;
  background: white;
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  height: fit-content;
}

.settings-menu-item {
  display: block;
  padding: var(--space-md);
  color: var(--color-text);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xs);
  transition: background 0.2s;
}

.settings-menu-item:hover {
  background: var(--color-bg-secondary);
}

.settings-menu-item.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-primary);
  font-weight: var(--font-medium);
}

.settings-content {
  flex: 1;
  background: white;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.settings-tab {
  display: none;
}

.settings-tab.active {
  display: block;
}

.settings-tab h3 {
  font-size: var(--font-xl);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-xl);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  font-size: var(--font-sm);
  font-weight: var(--font-medium);
  margin-bottom: var(--space-sm);
  color: var(--color-text);
}

.form-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-base);
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.profile-photo-upload {
  display: flex;
  gap: var(--space-xl);
  align-items: center;
  margin-bottom: var(--space-xl);
}

.profile-photo-preview {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-2xl);
  font-weight: var(--font-bold);
}

.profile-photo-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-base);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
  box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
  background: var(--color-bg-tertiary);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

/* Rejection Reason Modal Styles (v4.4.10) */
.rejection-option {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.rejection-option:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-primary);
}

.rejection-option input[type="radio"] {
  margin-right: 12px;
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
}

.rejection-option span {
  font-size: var(--font-md);
  color: var(--color-text);
}

.rejection-option:has(input:checked) {
  background: rgba(79, 70, 229, 0.1);
  border-color: var(--color-primary);
}

.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-sm {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-sm);
}

.btn-icon {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  background: white;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--color-bg-secondary);
}

.btn-back {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  background: white;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

.btn-back:hover {
  background: var(--color-bg-secondary);
}

.btn-close-view {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-full);
  font-size: var(--font-2xl);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
}

.btn-close-view:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

/* ============================================================================
   Forms
   ============================================================================ */

.select-input {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  background: white;
  cursor: pointer;
}

.select-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* ============================================================================
   Modals
   ============================================================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
  pointer-events: auto;
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 500px;
  margin: 10vh auto;
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-xl);
}

.modal-content h3 {
  font-size: var(--font-xl);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-lg);
}

.modal-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  justify-content: flex-end;
}

/* Modal Dialog Variant */
.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Add Relationship Modal must appear above Family Member Modal */
#addRelationshipModal {
  z-index: 10001;
}

#addRelationshipModal .modal-overlay {
  z-index: 10000;
}

#addRelationshipModal .modal-dialog {
  z-index: 10002;
}

/* Feedback Modal must appear above all other modals */
#feedbackModal {
  z-index: 10001;
}

#feedbackModal .modal-overlay {
  z-index: 10000;
}

#feedbackModal .modal-dialog {
  z-index: 10002;
}

.modal-dialog {
  position: relative;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1001;
}

.modal-dialog.modal-large {
  max-width: 800px;
}

.modal-dialog.modal-small {
  max-width: 400px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #1f2937;
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #6b7280;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem;
  border-top: 1px solid #e5e7eb;
}

/* Form Styles */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: #374151;
  font-size: 0.875rem;
}

.form-input {
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

.text-warning {
  color: #dc2626;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Responsive Form Layout */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   Toast Notifications
   ============================================================================ */

.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + var(--space-md));
  right: var(--space-md);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 300px;
  animation: slideInRight 0.3s;
}

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

.toast-success {
  border-left: 4px solid var(--color-success);
}

.toast-error {
  border-left: 4px solid var(--color-danger);
}

.toast-info {
  border-left: 4px solid var(--color-primary);
}

.toast-icon {
  font-size: var(--font-xl);
}

.toast-message {
  flex: 1;
  font-size: var(--font-sm);
}

.toast-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #666;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.toast-close:hover {
  background: rgba(0,0,0,0.1);
  color: #333;
}

.toast-error .toast-close {
  color: var(--color-danger);
}

/* ============================================================================
   Loading Spinner Overlay (v3.1.0)
   ============================================================================ */

#globalLoadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

#globalLoadingOverlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-spinner-content {
  background: white;
  padding: var(--space-xl) var(--space-2xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  text-align: center;
  min-width: 200px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-bg-tertiary);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-md);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-message {
  font-size: var(--font-base);
  color: var(--color-text);
  font-weight: 500;
}

/* v4.3.1: Dynamically created global spinner (from utils.js showLoadingSpinner) */
.global-loading-spinner,
#globalLoadingSpinner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

.global-loading-spinner .spinner-content {
  background: white;
  padding: 2rem 3rem;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  text-align: center;
  min-width: 200px;
}

.global-loading-spinner .spinner-icon {
  width: 48px;
  height: 48px;
  border: 4px solid #e5e7eb;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

.global-loading-spinner .spinner-message {
  font-size: 1rem;
  color: #374151;
  font-weight: 600;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 1024px) {
  .side-nav {
    transform: translateX(-100%);
  }

  .side-nav.active {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .media-layout {
    flex-direction: column;
  }

  .media-filters {
    width: 100%;
  }

  .settings-layout {
    flex-direction: column;
  }

  .settings-sidebar {
    width: 100%;
  }
}

@media (max-width: 768px) {
  :root {
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
  }

  .nav-center {
    display: none;
  }

  .main-content {
    padding: var(--space-md);
  }

  .media-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .collections-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-charts {
    grid-template-columns: 1fr;
  }

  .review-container {
    grid-template-columns: 1fr;
  }

  .lightbox-body {
    flex-direction: column;
  }

  .lightbox-sidebar {
    width: 100%;
  }

  .profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .media-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-cards {
    grid-template-columns: 1fr;
  }

  .hero-title {
    font-size: var(--font-2xl);
  }
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

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

.text-light {
  color: var(--color-text-light);
}

.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

/* ============================================================================
   Training Photos Styles
   ============================================================================ */

.training-photos-status-message {
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: none;
}

.training-photos-status-message.training-photos-status-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
  display: block;
}

.training-photos-status-message.training-photos-status-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
  display: block;
}

.training-photos-age-group-selector {
  margin: 20px 0;
}

.training-photos-age-group-selector label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1f2937;
}

.training-photos-age-group-selector select {
  width: 100%;
  max-width: 400px;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 16px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.training-photos-age-group-selector select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.training-photos-camera-section {
  margin: 20px 0;
}

.training-photos-camera-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px rgba(102, 126, 234, 0.3);
}

.training-photos-camera-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 12px rgba(102, 126, 234, 0.4);
}

.training-photos-camera-btn:active {
  transform: translateY(0);
}

.training-photos-camera-icon {
  font-size: 24px;
}

.training-photos-spinner {
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: training-photos-spin 1s linear infinite;
  display: none;
}

@keyframes training-photos-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.training-photos-preview-section {
  margin: 20px 0;
  padding: 20px;
  background: #f9fafb;
  border-radius: 12px;
}

.training-photos-preview-section h3 {
  margin-top: 0;
  color: #1f2937;
}

.training-photos-photo-grid {
  margin: 30px 0;
}

.training-photos-age-group-section {
  margin-bottom: 30px;
}

.training-photos-age-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e5e7eb;
}

.training-photos-age-group-title {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

.training-photos-photo-count {
  background: #667eea;
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.training-photos-photos-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.training-photos-photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #e0e0e0;
  transition: all 0.2s ease;
}

.training-photos-photo-item:hover {
  border-color: #667eea;
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.2);
}

.training-photos-photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.training-photos-photo-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.training-photos-photo-item:hover .training-photos-photo-delete {
  opacity: 1;
}

.training-photos-photo-delete:hover {
  background: rgba(220, 38, 38, 1);
}

.training-photos-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #9ca3af;
  background: #f9fafb;
  border-radius: 12px;
  border: 2px dashed #e5e7eb;
}

.training-photos-empty-state p {
  margin: 0;
  font-size: 16px;
}

/* Mobile Optimization for Training Photos */
@media (max-width: 768px) {
  .training-photos-camera-btn {
    width: 100%;
    justify-content: center;
    font-size: 16px;
    padding: 18px;
    min-height: 60px;
  }

  .training-photos-age-group-selector select {
    max-width: 100%;
    font-size: 16px;
    min-height: 50px;
  }

  .training-photos-photos-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .training-photos-photo-delete {
    opacity: 1;
  }
}

/* ============================================================================
   Mobile-First Person Profile (v1.0)
   Contribution-focused design with large touch-friendly buttons
   ============================================================================ */

/* Mobile Profile Header */
.mobile-profile-header {
  padding: var(--space-md);
  background: white;
  border-bottom: 1px solid var(--color-border);
}

.btn-back-mobile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: var(--font-lg);
  font-weight: 500;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  transition: background-color 0.2s;
}

.btn-back-mobile:hover {
  background: var(--color-bg-secondary);
}

.btn-back-mobile:active {
  background: var(--color-bg-tertiary);
}

.back-arrow {
  font-size: 1.5rem;
}

/* Person Card (Mobile-First) */
.person-card-mobile {
  padding: var(--space-xl);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-align: center;
}

.profile-photo-container {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-lg);
}

.profile-photo-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: white;
  color: #667eea;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  border: 4px solid white;
}

.profile-photo-circle img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.person-info-mobile {
  text-align: center;
}

.person-name-mobile {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: white;
}

.person-dates-mobile {
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: var(--space-md);
}

.person-stats-row {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-top: var(--space-lg);
  flex-wrap: wrap;
}

.person-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-lg);
}

.person-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.person-stat-label {
  font-size: 0.875rem;
  opacity: 0.9;
  margin-top: 0.25rem;
}

/* Contribution Section (LARGE BUTTONS) */
.contribution-section {
  padding: var(--space-xl);
  background: white;
}

.contribution-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
  color: var(--color-text);
}

.contribution-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: 1.5rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: var(--space-lg);
  /* Touch-friendly minimum size */
  min-height: 80px;
  position: relative;
  overflow: hidden;
}

.contribution-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 0;
}

.contribution-btn:hover::before {
  opacity: 0.05;
}

.contribution-btn:active {
  transform: scale(0.98);
}

.contribution-btn-icon {
  font-size: 2.5rem;
  flex-shrink: 0;
  z-index: 1;
}

.contribution-btn-content {
  flex: 1;
  text-align: left;
  z-index: 1;
}

.contribution-btn-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.contribution-btn-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-light);
}

.contribution-btn-arrow {
  font-size: 1.5rem;
  color: var(--color-text-lighter);
  flex-shrink: 0;
  z-index: 1;
}

.training-btn {
  border-color: #667eea;
}

.training-btn:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.document-btn {
  border-color: #10b981;
}

.document-btn:hover {
  border-color: #10b981;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

/* Existing Content Section (Collapsible) */
.existing-content-section {
  padding: var(--space-xl);
  background: var(--color-bg-secondary);
}

.existing-content-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text);
  transition: all 0.2s;
}

.existing-content-toggle:hover {
  background: var(--color-bg-secondary);
}

.existing-content-toggle:active {
  transform: scale(0.98);
}

#existingContentToggleIcon {
  transition: transform 0.2s;
}

#existingContentToggleIcon.rotated {
  transform: rotate(180deg);
}

.existing-content-container {
  margin-top: var(--space-lg);
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Mobile Tabs */
.profile-tabs-mobile {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: white;
  overflow-x: auto;
}

.tab-button-mobile {
  flex: 1;
  min-width: 120px;
  padding: 1rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--color-text-light);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-button-mobile.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.profile-tab-content-mobile {
  padding: var(--space-lg);
}

/* ============================================================================
   Mobile Modals (Full-Screen)
   ============================================================================ */

.mobile-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  z-index: 10000;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.mobile-modal.active {
  display: flex;
}

.mobile-modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  background: white;
  position: sticky;
  top: 0;
  z-index: 100;
}

.mobile-modal-back {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.5rem;
  margin-left: -0.5rem;
  border-radius: var(--radius-md);
  transition: background-color 0.2s;
}

.mobile-modal-back:hover {
  background: var(--color-bg-secondary);
}

/* Mobile Modal Close Button (X) - v3.5.2 */
.mobile-modal-close {
  background: none;
  border: none;
  font-size: 1.75rem;
  cursor: pointer;
  color: #6b7280;
  padding: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: background-color 0.2s, color 0.2s;
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
}

.mobile-modal-close:hover {
  background: var(--color-bg-secondary);
  color: #1f2937;
}

/* Update header to support close button positioning */
.mobile-modal-header {
  position: relative;
}

.mobile-modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: var(--space-md);
  color: var(--color-text);
}

.mobile-modal-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  -webkit-overflow-scrolling: touch;
}

/* Modal Help Text */
.modal-help-text {
  margin-bottom: var(--space-xl);
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
}

.modal-help-text p {
  margin-bottom: 0.75rem;
  line-height: 1.6;
  color: var(--color-text);
}

.modal-help-text p:last-child {
  margin-bottom: 0;
}

/* Age Group Selector (Mobile) */
.age-group-selector-mobile {
  margin-bottom: var(--space-xl);
}

.mobile-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--color-text);
  font-size: 1rem;
}

.mobile-select {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: white;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.2s;
  /* iOS appearance fix */
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 3rem;
}

.mobile-select:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* Mobile Camera Button */
.mobile-camera-btn {
  width: 100%;
  padding: 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: var(--radius-xl);
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  min-height: 64px;
}

.mobile-camera-btn:active {
  transform: scale(0.98);
}

.camera-icon {
  font-size: 1.75rem;
}

.camera-text {
  font-size: 1.125rem;
}

/* Mobile Preview Section */
.mobile-preview-section {
  margin-top: var(--space-xl);
}

.mobile-preview-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.mobile-preview-image {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
  margin-bottom: var(--space-lg);
}

.mobile-upload-btn {
  width: 100%;
  padding: 1.25rem;
  background: var(--color-success);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 56px;
}

.mobile-upload-btn:active {
  transform: scale(0.98);
}

.mobile-upload-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Existing Training Photos Grid */
.existing-training-photos {
  margin-top: var(--space-2xl);
}

/* Family Member Modal Loading Overlay */
.fm-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}

.fm-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-2xl);
  color: var(--color-text-muted);
}

.fm-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: fm-spin 1s linear infinite;
}

@keyframes fm-spin {
  to { transform: rotate(360deg); }
}

.fm-loading-state p {
  font-size: var(--font-lg);
  margin: 0;
}

/* ============================================================================
   Person Modal Sections (Mobile-First)
   ============================================================================ */

.person-section {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  border: 1px solid var(--color-border);
}

.person-section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-help-text {
  color: #6b7280;
  font-size: 0.9375rem;
  line-height: 1.5;
  margin-bottom: var(--space-md);
}

.form-help-text {
  color: #6b7280;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  display: block;
}

.mobile-input {
  width: 100%;
  padding: 0.875rem;
  font-size: 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: white;
  color: var(--color-text);
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.mobile-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.mobile-textarea {
  width: 100%;
  padding: 0.875rem;
  font-size: 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: white;
  color: var(--color-text);
  transition: border-color 0.2s;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  resize: vertical;
  min-height: 120px;
}

.mobile-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.mobile-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  padding: 0.5rem 0;
}

.mobile-checkbox-label input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}

.mobile-checkbox-label span {
  font-size: 1rem;
  color: var(--color-text);
}

.mobile-action-btn {
  width: 100%;
  padding: 1.125rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  min-height: 56px;
  margin-bottom: var(--space-md);
}

.mobile-action-btn:active {
  transform: scale(0.98);
}

.btn-icon {
  font-size: 1.5rem;
}

.btn-text {
  font-size: 1rem;
}

/* Relationship Cards */
.relationship-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.relationship-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.relationship-card-info {
  flex: 1;
}

.relationship-type {
  font-size: 0.8125rem;
  color: #6b7280;
  text-transform: capitalize;
  margin-bottom: 0.25rem;
}

.relationship-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

/* Training Photos Grid */
.training-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.training-photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--color-border);
}

.training-photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Documents Grid */
.documents-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.document-item {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.875rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.document-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

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

.document-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-date {
  font-size: 0.8125rem;
  color: #6b7280;
}

/* Biography Tabs */
.bio-tabs {
  display: flex;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid var(--color-border);
}

.bio-tab {
  flex: 1;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #6b7280;
  transition: all 0.2s;
}

.bio-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.bio-preview {
  padding: 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-secondary);
  min-height: 150px;
  line-height: 1.6;
}

/* Mobile Modal Footer (Fixed Bottom) */
.mobile-modal-footer {
  position: sticky;
  bottom: 0;
  padding: var(--space-lg);
  background: white;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: var(--space-md);
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.btn-secondary-mobile,
.btn-primary-mobile {
  flex: 1;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
}

.btn-secondary-mobile {
  background: white;
  color: var(--color-text);
  border: 2px solid var(--color-border);
}

.btn-secondary-mobile:active {
  background: var(--color-bg-secondary);
}

.btn-primary-mobile {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-primary-mobile:active {
  transform: scale(0.98);
}

/* ============================================================================
   AI Analysis Modal (Full-Screen Conversational)
   ============================================================================ */

.ai-modal-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  z-index: 20000;
  display: none;
  flex-direction: column;
}

.ai-modal-fullscreen.active {
  display: flex;
}

.ai-modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  background: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.ai-modal-close {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  transition: background-color 0.2s;
}

.ai-modal-close:hover {
  background: var(--color-bg-secondary);
}

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

.ai-modal-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* AI Document Preview */
.ai-document-preview {
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.ai-document-image {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: white;
}

/* AI Conversation Area */
.ai-conversation {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  -webkit-overflow-scrolling: touch;
}

.ai-message {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.ai-message.user {
  flex-direction: row-reverse;
}

.ai-message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.ai-message.user .ai-message-avatar {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.ai-message-bubble {
  max-width: 75%;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: var(--color-bg-secondary);
  color: var(--color-text);
  line-height: 1.6;
}

.ai-message.user .ai-message-bubble {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

/* AI Input Area */
.ai-input-area {
  padding: var(--space-lg);
  border-top: 1px solid var(--color-border);
  background: white;
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.ai-input-field {
  flex: 1;
  padding: 0.875rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 1rem;
  background: var(--color-bg-secondary);
  color: var(--color-text);
}

.ai-input-field:focus {
  outline: none;
  border-color: var(--color-primary);
  background: white;
}

.ai-send-btn {
  padding: 0.875rem 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-send-btn:active {
  transform: scale(0.95);
}

.ai-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Voice Recording Button (v3.5.8) */
.ai-voice-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-voice-btn:active {
  transform: scale(0.95);
}

.ai-voice-btn.recording {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  animation: pulse-recording 1s infinite;
}

@keyframes pulse-recording {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

/* AI Modal Footer (v4.6.18 - full width, cache-bust fix confirmed) */
.ai-modal-footer {
  padding: 0;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
}
.ai-modal-footer > * {
  width: 100%;
  max-width: none;
}

.ai-save-btn {
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 200px;
}

.ai-save-btn:active {
  transform: scale(0.98);
}

.ai-save-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* AI Analysis Results (v3.1.0) */
.ai-analysis-results {
  margin-top: 1rem;
}

.ai-result-section {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.ai-result-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.ai-result-section strong {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.ai-result-section ul {
  margin: 0.5rem 0 0 1.25rem;
  padding: 0;
}

.ai-result-section li {
  margin-bottom: 0.25rem;
}

.ai-extracted-text {
  background: rgba(0, 0, 0, 0.04);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-family: monospace;
  font-size: 0.875rem;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

.ai-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.ai-tag {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}

/* ============================================================================
   Mobile Responsive Enhancements
   ============================================================================ */

@media (max-width: 768px) {
  .person-name-mobile {
    font-size: 1.5rem;
  }

  .contribution-btn {
    padding: 1.25rem;
  }

  .contribution-btn-icon {
    font-size: 2rem;
  }

  .contribution-btn-title {
    font-size: 1rem;
  }

  .ai-message-bubble {
    max-width: 85%;
  }
}

@media (min-width: 769px) {
  /* On desktop, center the mobile views */
  #view-person-profile {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    box-shadow: var(--shadow-xl);
  }

  .mobile-modal {
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: var(--shadow-xl);
  }

  .ai-modal-fullscreen {
    max-width: 800px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: var(--shadow-xl);
  }
}

/* ============================================================================
   Family Navigator - Mobile-First Hierarchical Navigation
   ============================================================================ */

/* Desktop: Side panel */
@media (min-width: 1024px) {
  .family-navigator {
    position: relative;
    right: auto;
    top: auto;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    height: calc(100vh - var(--nav-height) - 100px);
    overflow-y: auto;
    border: none;
    background: white;
    z-index: 1;
    display: flex;
    flex-direction: column;
  }

  .tree-canvas-fullwidth {
    margin-right: 0 !important;
  }
}

/* Mobile: ALWAYS VISIBLE - Family Navigator is the hero screen */
@media (max-width: 1023px) {
  .family-navigator {
    position: relative;
    top: auto;
    left: auto;
    width: 100%;
    height: calc(100vh - var(--nav-height) - 100px);
    overflow-y: auto;
    background: white;
    z-index: 1;
    display: flex; /* ALWAYS VISIBLE - Hero screen */
    flex-direction: column;
  }

  .family-navigator.active {
    display: flex;
    flex-direction: column;
  }
}

/* Navigator header */
.family-navigator-header {
  padding: var(--space-lg);
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  color: white;
  border-bottom: 1px solid var(--color-border);
}

.family-navigator-header h3 {
  font-size: var(--font-xl);
  font-weight: var(--font-bold);
  margin: 0 0 var(--space-xs) 0;
}

.nav-description {
  font-size: var(--font-sm);
  opacity: 0.8;
  margin: 0;
}

/* Compact Navigator Header */
.family-navigator-header-compact {
  padding: 1rem;
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  color: white;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-back-btn-compact {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-back-btn-compact:hover {
  background: rgba(255, 255, 255, 0.2);
}

.nav-back-btn-compact:active {
  transform: scale(0.95);
}

.nav-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-header-info h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
}

.nav-stats-compact {
  font-size: 0.75rem;
  opacity: 0.8;
}

.nav-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Navigator content */
.family-navigator-content {
  flex: 1;
  padding: var(--space-lg);
  overflow-y: auto;
}

.nav-loading,
.nav-error {
  padding: var(--space-xl);
  text-align: center;
  color: var(--color-text-light);
}

/* Navigation header (context) */
.nav-header {
  padding: var(--space-lg);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
}

.nav-header-title {
  font-size: var(--font-xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-xs);
}

.nav-header-subtitle {
  font-size: var(--font-sm);
  opacity: 0.9;
}

/* Back button */
.nav-back-button {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-secondary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-md);
  transition: background 0.2s, transform 0.2s;
  width: fit-content;
}

.nav-back-button:hover {
  background: var(--color-border);
  transform: translateX(-2px);
}

/* Controls list */
.nav-controls-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Couple control - compact for mobile fit */
.nav-couple-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 56px;
}

.nav-couple-control:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.nav-couple-control:active {
  transform: translateY(0);
}

.nav-couple-names {
  font-size: var(--font-base);
  font-weight: var(--font-semibold);
  line-height: 1.3;
}

.nav-couple-arrow {
  font-size: 20px;
  opacity: 0.9;
}

/* Individual control - compact for mobile fit */
.nav-individual-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: white;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-left-color 0.2s;
  min-height: 48px;
}

.nav-individual-control:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-left-width: 6px;
}

.nav-individual-control:active {
  transform: translateY(0);
}

.nav-individual-name {
  font-size: var(--font-sm);
  font-weight: var(--font-medium);
  color: var(--color-text);
  line-height: 1.3;
}

.nav-individual-icon {
  font-size: 16px;
  color: var(--color-text-light);
}

/* Scrollbar styling for navigator */
.family-navigator-content::-webkit-scrollbar {
  width: 8px;
}

.family-navigator-content::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

.family-navigator-content::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-sm);
}

.family-navigator-content::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-lighter);
}

/* Mobile: Compact controls to fit without scrolling */
@media (max-width: 1023px) {
  .nav-controls-list {
    gap: var(--space-sm);
  }

  .nav-couple-control {
    min-height: 52px;
    padding: var(--space-sm) var(--space-md);
  }

  .nav-individual-control {
    min-height: 44px;
    padding: var(--space-xs) var(--space-sm);
  }

  .nav-couple-names {
    font-size: var(--font-sm);
  }

  .nav-individual-name {
    font-size: var(--font-xs);
  }

  .nav-couple-arrow {
    font-size: 18px;
  }

  .nav-individual-icon {
    font-size: 14px;
  }
}

/* ============================================================================
   Family Member Modal (Mobile-First, Unified View/Edit)
   ============================================================================ */

.family-member-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f9fafb;
  z-index: 10000;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.family-member-modal.active {
  display: flex;
}

/* Header */
.family-member-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.family-member-back {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.family-member-back:active {
  background: rgba(255, 255, 255, 0.3);
}

.family-member-title {
  flex: 1;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.family-member-edit-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.family-member-edit-toggle:active {
  background: rgba(255, 255, 255, 0.3);
}

.family-member-edit-toggle.editing {
  background: white;
  color: #667eea;
}

/* Content */
.family-member-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 2rem;
}

/* Profile Hero Section */
.profile-hero {
  background: white;
  padding: 2rem 1rem;
  text-align: center;
  border-bottom: 1px solid #e5e7eb;
}

.profile-headshot-container {
  position: relative;
  display: inline-block;
  cursor: pointer;
  margin-bottom: 1rem;
}

.profile-headshot,
.profile-headshot-placeholder {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.profile-headshot-placeholder {
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
}

.profile-headshot-hint {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: #6b7280;
  font-weight: 500;
}

.profile-info {
  margin-top: 0.5rem;
}

.profile-dates {
  font-size: 1rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.profile-location {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: #9ca3af;
}

/* Quick Stats */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  padding: 1rem;
  background: #f9fafb;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid #e5e7eb;
}

.stat-card:active {
  transform: scale(0.95);
  background: #f9fafb;
}

.stat-icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Compact stat card (reduced height) */
.stat-card.compact {
  padding: 0.5rem;
}

.stat-card.compact .stat-icon {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.stat-card.compact .stat-value {
  font-size: 1.125rem;
  margin-bottom: 0.125rem;
}

.stat-card.compact .stat-label {
  font-size: 0.625rem;
}

/* Family Sections */
.family-section {
  background: white;
  margin: 0.75rem;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

.family-section-header {
  padding: 1rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.family-section-header:active {
  background: #f3f4f6;
}

.family-section-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.section-icon {
  color: #667eea;
}

.section-chevron {
  color: #9ca3af;
  transition: transform 0.3s;
}

.section-chevron.expanded {
  transform: rotate(0deg);
}

.section-chevron.collapsed {
  transform: rotate(-90deg);
}

.family-section-content {
  padding: 1rem;
}

.family-section-content.collapsed {
  display: none;
}

.section-hint {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* Relationship Cards */
.relationship-person-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 0.625rem;
  cursor: pointer;
  transition: all 0.2s;
}

.relationship-person-card:active {
  background: #f3f4f6;
  transform: scale(0.98);
}

.relationship-person-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e5e7eb;
}

.relationship-person-info {
  flex: 1;
}

.relationship-type-label {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.relationship-person-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #1f2937;
}

/* Training Photos Grid */
.training-photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.training-photo-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid #e5e7eb;
  transition: all 0.2s;
}

.training-photo-card:active {
  transform: scale(0.95);
  border-color: #667eea;
}

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

.training-photo-age-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: white;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  line-height: 1;
}

/* v4.3.1: Training photo action buttons */
.training-photo-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.training-photo-card:hover .training-photo-actions,
.training-photo-card:focus-within .training-photo-actions {
  opacity: 1;
}

.training-photo-actions button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: transform 0.2s;
}

.training-photo-actions button:active {
  transform: scale(0.9);
}

.set-profile-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.delete-photo-btn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

/* Documents List */
.documents-list {
  margin-bottom: 1rem;
}

.document-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 0.625rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid #e5e7eb;
}

.document-card:active {
  background: #f3f4f6;
  transform: scale(0.98);
}

.document-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

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

.document-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-date {
  font-size: 0.75rem;
  color: #6b7280;
}

/* Add Content Button */
.add-content-btn {
  width: 100%;
  padding: 0.875rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.add-content-btn:active {
  transform: scale(0.98);
}

/* Biography */
.biography-display {
  line-height: 1.7;
  color: #374151;
  font-size: 0.9375rem;
}

.biography-display p {
  margin-bottom: 1rem;
}

.biography-display p:last-child {
  margin-bottom: 0;
}

.empty-state {
  color: #9ca3af;
  font-style: italic;
  text-align: center;
  padding: 2rem 1rem;
}

.link-text {
  color: #667eea;
  cursor: pointer;
  text-decoration: underline;
}

.link-text:hover {
  color: #764ba2;
}

.biography-edit {
  margin-top: 1rem;
}

.biography-textarea {
  width: 100%;
  padding: 0.875rem;
  font-size: 0.9375rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  resize: vertical;
  min-height: 150px;
}

.biography-textarea:focus {
  outline: none;
  border-color: #667eea;
}

/* Edit Mode Form Fields */
.edit-only {
  display: none;
}

.edit-only.visible {
  display: block;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.form-field {
  margin-bottom: 0.75rem;
}

.field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
}

.field-input {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.9375rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  transition: border-color 0.2s;
}

.field-input:focus {
  outline: none;
  border-color: #667eea;
}

.field-checkbox {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  user-select: none;
}

.field-checkbox input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  cursor: pointer;
}

.field-checkbox span {
  font-size: 0.9375rem;
  color: #374151;
}

/* Footer */
.family-member-footer {
  background: white;
  border-top: 1px solid #e5e7eb;
  padding: 1rem;
  display: flex;
  gap: 0.75rem;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.btn-footer-secondary,
.btn-footer-primary {
  flex: 1;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-footer-secondary {
  background: white;
  color: #374151;
  border: 2px solid #e5e7eb;
}

.btn-footer-secondary:active {
  background: #f9fafb;
}

.btn-footer-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.btn-footer-primary:active {
  transform: scale(0.98);
}

/* Responsive - Tablet and Desktop */
@media (min-width: 768px) {
  .family-member-modal {
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
  }

  .training-photos-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Relationship Editing */
.relationship-person-card-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.relationship-delete-btn {
  background: #fee2e2;
  border: none;
  border-radius: 0.375rem;
  padding: 0.5rem;
  cursor: pointer;
  font-size: 1.125rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.relationship-delete-btn:hover {
  background: #fecaca;
  transform: scale(1.1);
}

.relationship-delete-btn:active {
  transform: scale(0.95);
}

/* View All Button for Siblings/Cousins */
.view-all-btn {
  width: 100%;
  padding: 0.625rem 1rem;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #6366f1;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.5rem;
}

.view-all-btn:hover {
  background: #e5e7eb;
  color: #4f46e5;
}

.view-all-btn:active {
  transform: scale(0.98);
}

/* Add Relationship Button */
.add-relationship-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.add-relationship-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.add-relationship-btn:active {
  transform: translateY(0);
}

/* Modal Styles - Removed duplicate (using styles from line 2447 instead) */

.modal-content {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  transition: all 0.2s;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.modal-body {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #374151;
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e5e7eb;
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: all 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modal-footer {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
  margin-top: 1rem;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.btn-danger {
  background: #ef4444;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

/* ========================================
   v3.0 Training Photo Review Modal Styles
   ======================================== */

.photo-preview {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 20px;
}

.quality-assessment {
  margin-top: 20px;
}

.quality-score {
  text-align: center;
  margin-bottom: 20px;
}

.score-value {
  font-size: 48px;
  font-weight: bold;
  color: #10b981;
  display: block;
}

.score-label {
  font-size: 14px;
  color: #6b7280;
  display: block;
  margin-top: 8px;
}

.quality-factors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.factor {
  padding: 12px;
  background: #f3f4f6;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.factor .icon {
  font-size: 20px;
}

.recommendation {
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 15px;
}

.recommendation .icon {
  font-size: 24px;
}

.recommendation.accept {
  background: #d1fae5;
  color: #065f46;
  border: 2px solid #10b981;
}

.recommendation.reject {
  background: #fee2e2;
  color: #991b1b;
  border: 2px solid #ef4444;
}

.issues {
  padding: 12px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  margin-bottom: 16px;
}

.issues ul {
  margin: 8px 0;
  padding-left: 20px;
}

.issues li {
  margin: 4px 0;
  color: #92400e;
}

.explanation {
  color: #374151;
  line-height: 1.6;
  font-size: 14px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  border-left: 4px solid #667eea;
}

/* ========================================
   v3.0 Document Review Modal Styles
   ======================================== */

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

.document-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (min-width: 768px) {
  .document-layout {
    flex-direction: row;
  }

  .document-preview {
    flex: 1;
    min-width: 300px;
  }

  .document-metadata {
    flex: 1;
    min-width: 400px;
  }
}

.document-preview {
  display: flex;
  flex-direction: column;
}

.doc-image {
  width: 100%;
  max-height: 600px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.document-metadata {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-confidence {
  display: block;
  font-size: 12px;
  color: #10b981;
  margin-top: 4px;
  font-weight: 500;
}

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  min-height: 44px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #667eea;
  color: white;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
}

.chip button {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  margin: 0;
  min-width: 20px;
  min-height: 20px;
  line-height: 1;
}

.chip button:hover {
  opacity: 0.8;
}

.conversation {
  margin-top: 24px;
  border-top: 1px solid #e5e7eb;
  padding-top: 24px;
}

.conversation label {
  display: block;
  font-weight: 600;
  margin-bottom: 12px;
  color: #374151;
}

.chat-history {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 12px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.chat-history:empty::before {
  content: "No messages yet. Ask Claude a question about this document.";
  color: #9ca3af;
  font-style: italic;
  font-size: 14px;
}

.chat-message {
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  line-height: 1.5;
  font-size: 14px;
}

.chat-message.user {
  background: #e0e7ff;
  color: #1e40af;
  text-align: right;
  margin-left: 20%;
}

.chat-message.assistant {
  background: #f3f4f6;
  color: #1f2937;
  margin-right: 20%;
}

.chat-input {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.chat-input input {
  flex: 1;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 16px;
}

.chat-input button {
  padding: 12px 24px;
  min-width: 80px;
  white-space: nowrap;
}

/* Mobile optimizations for v3.0 modals */
@media (max-width: 768px) {
  .photo-preview {
    max-height: 250px;
  }

  .quality-factors {
    grid-template-columns: 1fr;
  }

  .score-value {
    font-size: 36px;
  }

  .document-modal .modal-content {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .doc-image {
    max-height: 300px;
  }

  .chat-message.user {
    margin-left: 10%;
  }

  .chat-message.assistant {
    margin-right: 10%;
  }
}

/* ============================================================================
   FAMILY MEMBER MODAL v4.0 - Compact Hero + Expandable Panels
   Compact centered modal design (menu-style) - same on all devices
   ============================================================================ */

/* v5.1.1: Proper backdrop element that blocks click-through to underlying page */
.fm-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: none;
  pointer-events: auto;
}

.fm-modal-backdrop.active {
  display: block;
}

/* v5.1.5: Disable pointer-events on backdrop when panel is open to prevent touch bleed-through on iOS Safari */
.fm-modal-backdrop.panel-open {
  pointer-events: none;
}

/* Main Modal Container - Compact Centered Card */
.fm-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;
  max-width: 420px;
  max-height: 85vh;
  background: #f8f9fa;
  z-index: 10000;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.fm-modal.active {
  display: flex;
}

/* v5.1.1: Removed ::before pseudo-element backdrop - now using real backdrop element above */

/* ======================= HERO SCREEN ======================= */

.fm-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
  background: linear-gradient(180deg, #667eea 0%, #764ba2 35%, #f8f9fa 35%);
}

/* Compact Header */
.fm-hero-header {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
}

.fm-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
}

.fm-close-btn:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.95);
}

/* Feedback button in modal header (v4.6.25) */
.fm-feedback-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
  font-size: 16px;
  margin-right: 8px;
}

.fm-feedback-btn:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.95);
}

/* Profile Section - v5.0.4: Reduced padding for compact layout */
.fm-hero-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 12px;
  margin-top: -8px;
}

/* Headshot */
.fm-headshot-wrapper {
  position: relative;
  cursor: pointer;
}

.fm-headshot,
.fm-headshot-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  object-fit: cover;
}

.fm-headshot-placeholder {
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6366f1;
}

.fm-headshot-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 50%;
  border: 2px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

/* Name & Dates */
.fm-hero-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  margin: 12px 0 4px;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.fm-hero-dates {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Contribution Stats Badge */
.fm-hero-contributions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  cursor: help;
}

.fm-hero-contributions::before {
  content: '🏆';
}

/* Stats Row - v5.0.4: Reduced margins for compact layout */
.fm-stats-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 12px;
  margin: 12px 0;
}

.fm-stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: white;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  min-width: 72px;
}

.fm-stat-icon {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

.fm-stat-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1f2937;
}

.fm-stat-label {
  font-size: 0.6875rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ======================= ACTION BUTTONS GRID ======================= */
/* v5.0.4: Reduced whitespace for more compact mobile layout */

.fm-actions-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.fm-action-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: white;
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.fm-action-card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.fm-action-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

/* Color Variants */
.fm-action-demographics::before { background: linear-gradient(180deg, #3b82f6, #2563eb); }
.fm-action-document::before { background: linear-gradient(180deg, #8b5cf6, #7c3aed); }
.fm-action-face::before { background: linear-gradient(180deg, #10b981, #059669); }
.fm-action-voice::before { background: linear-gradient(180deg, #f59e0b, #d97706); }
.fm-action-family::before { background: linear-gradient(180deg, #ec4899, #db2777); }

.fm-action-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fm-action-demographics .fm-action-icon-wrap { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #2563eb; }
.fm-action-document .fm-action-icon-wrap { background: linear-gradient(135deg, #ede9fe, #ddd6fe); color: #7c3aed; }
.fm-action-face .fm-action-icon-wrap { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #059669; }
.fm-action-voice .fm-action-icon-wrap { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #d97706; }
.fm-action-family .fm-action-icon-wrap { background: linear-gradient(135deg, #fce7f3, #fbcfe8); color: #db2777; }

.fm-action-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fm-action-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
}

.fm-action-subtitle {
  font-size: 0.8125rem;
  color: #6b7280;
}

.fm-action-arrow {
  color: #9ca3af;
  flex-shrink: 0;
}

/* ======================= v4.9.0: 2-COLUMN TILE GRID ======================= */

.fm-tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  /* v5.0.6: Reduced gap and padding for compact layout */
  gap: 10px;
  padding: 0 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.fm-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* v5.0.6: Removed aspect-ratio: 1 and reduced min-height for compact layout */
  padding: 12px 8px;
  background: white;
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  min-height: 72px;
}

.fm-tile:active {
  transform: scale(0.96);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.fm-tile-icon {
  /* v5.0.6: Reduced icon size for compact layout */
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.fm-tile-icon svg {
  /* v5.0.6: Scale down icons */
  width: 24px;
  height: 24px;
}

.fm-tile-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1f2937;
  text-align: center;
  line-height: 1.2;
}

.fm-tile-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 12px;
  background: #ef4444;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Full-width tile for 7th item */
.fm-tile-wide {
  grid-column: span 2;
  aspect-ratio: auto;
  flex-direction: row;
  justify-content: flex-start;
  /* v5.0.6: Reduced gap/padding for compact layout */
  gap: 12px;
  padding: 10px 16px;
  min-height: 56px;
}

.fm-tile-wide .fm-tile-icon {
  margin-bottom: 0;
}

/* Color Variants */
.fm-tile-blue .fm-tile-icon { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #2563eb; }
.fm-tile-indigo .fm-tile-icon { background: linear-gradient(135deg, #e0e7ff, #c7d2fe); color: #4f46e5; }
.fm-tile-purple .fm-tile-icon { background: linear-gradient(135deg, #ede9fe, #ddd6fe); color: #7c3aed; }
.fm-tile-amber .fm-tile-icon { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #d97706; }
.fm-tile-green .fm-tile-icon { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #059669; }
.fm-tile-orange .fm-tile-icon { background: linear-gradient(135deg, #ffedd5, #fed7aa); color: #ea580c; }
.fm-tile-pink .fm-tile-icon { background: linear-gradient(135deg, #fce7f3, #fbcfe8); color: #db2777; }

/* Hover effects for desktop */
@media (hover: hover) {
  .fm-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  }
}

/* ======================= EXPANDABLE PANELS ======================= */

.fm-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f8f9fa;
  display: none;
  flex-direction: column;
  z-index: 10001;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

/* v5.1.6: Fixed iOS Safari & Chrome touch bug - explicit pointer-events and touch handling */
.fm-panel.active {
  display: flex;
  transform: translateX(0);
  pointer-events: auto;
  /* Ensure panel creates its own stacking context for proper event handling */
  isolation: isolate;
}

/* v5.1.6: Ensure all panel children receive touch/click events */
.fm-panel.active .fm-panel-content {
  pointer-events: auto;
  /* Enable touch scrolling */
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* v5.1.6: Force form elements to be interactive */
.fm-panel.active input,
.fm-panel.active select,
.fm-panel.active textarea,
.fm-panel.active button {
  pointer-events: auto !important;
  touch-action: manipulation;
  -webkit-user-select: text;
  user-select: text;
}

/* Panel Headers */
.fm-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  color: white;
  position: relative;
}

.fm-panel-header-blue { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }
.fm-panel-header-purple { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); }
.fm-panel-header-green { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.fm-panel-header-orange { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.fm-panel-header-pink { background: linear-gradient(135deg, #ec4899 0%, #db2777 100%); }

.fm-panel-back {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.fm-panel-back:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.95);
}

.fm-panel-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
  text-align: center;
  flex: 1;
}

.fm-panel-save,
.fm-panel-add {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.fm-panel-save:active,
.fm-panel-add:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.95);
}

/* Panel Content */
.fm-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.fm-panel-content-centered {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ======================= FORM STYLES ======================= */

.fm-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.fm-form-section {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.fm-form-section-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f3f4f6;
}

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

.fm-form-grid:last-child {
  margin-bottom: 0;
}

.fm-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fm-field-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #374151;
}

.fm-field-input,
.fm-field-textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  background: #fafafa;
  transition: all 0.2s;
  font-family: inherit;
}

.fm-field-input:focus,
.fm-field-textarea:focus {
  outline: none;
  border-color: #667eea;
  background: white;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.fm-field-textarea {
  resize: vertical;
  min-height: 120px;
}

.fm-field-hint {
  font-size: 0.75rem;
  color: #9ca3af;
}

.fm-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 0;
}

.fm-checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #667eea;
}

.fm-checkbox-text {
  font-size: 0.9375rem;
  color: #374151;
}

/* ======================= UPLOAD ZONE ======================= */

.fm-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  background: white;
  border: 2px dashed #d1d5db;
  border-radius: 20px;
  text-align: center;
  width: 100%;
  max-width: 320px;
  margin: 20px 0;
}

.fm-upload-icon {
  color: #9ca3af;
  margin-bottom: 16px;
}

.fm-upload-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 4px;
}

.fm-upload-subtitle {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0 0 20px;
}

.fm-upload-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.fm-upload-btn:active {
  transform: scale(0.98);
}

/* Mass Import Button */
.fm-mass-import-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  margin-top: 12px;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.fm-mass-import-btn:active {
  transform: scale(0.98);
}

.fm-upload-hint {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 16px;
  text-align: center;
}

/* Document Preview */
.fm-document-preview {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.fm-preview-image {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  margin-bottom: 16px;
}

.fm-preview-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* v4.6.42: Tablet+ horizontal layout for Add Document preview */
@media (min-width: 768px) {
  .fm-document-preview {
    max-width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
    text-align: left;
  }

  .fm-preview-image {
    max-height: 400px;
    margin-bottom: 0;
    width: 100%;
  }

  .fm-preview-controls {
    display: flex;
    flex-direction: column;
  }

  .fm-document-preview .fm-narrative-input {
    margin: 0 0 16px 0;
  }

  .fm-preview-actions {
    gap: 12px;
  }
}

@media (min-width: 1024px) {
  .fm-document-preview {
    gap: 32px;
  }

  .fm-preview-image {
    max-height: 500px;
  }
}

.fm-ai-analyze-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.fm-ai-sparkle {
  font-size: 1.25rem;
}

.fm-save-direct-btn {
  padding: 12px 24px;
  background: #f3f4f6;
  color: #4b5563;
  border: none;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
}

/* ======================= TRAINING PROGRESS ======================= */

.fm-training-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  background: white;
  border-radius: 20px;
  width: 100%;
  max-width: 280px;
  margin-bottom: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.fm-progress-ring {
  position: relative;
  width: 100px;
  height: 100px;
  margin-bottom: 12px;
}

.fm-progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.fm-progress-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: #1f2937;
  line-height: 1;
}

.fm-progress-label {
  display: block;
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 2px;
}

.fm-progress-hint {
  font-size: 0.8125rem;
  color: #6b7280;
  text-align: center;
  margin: 0;
}

/* Age Selector */
.fm-age-selector {
  width: 100%;
  max-width: 280px;
  margin-bottom: 20px;
}

/* Face Capture Button */
.fm-face-capture-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 32px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
  margin-bottom: 24px;
}

.fm-face-capture-btn:active {
  transform: scale(0.98);
}

/* Training Photos Grid */
.fm-training-photos-section {
  width: 100%;
  margin-top: 16px;
}

.fm-section-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 12px;
}

.fm-training-photos-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: white;
  padding: 16px;
  border-radius: 16px;
}

.fm-empty-state {
  text-align: center;
  padding: 24px;
  color: #9ca3af;
  font-size: 0.9375rem;
}

/* v3.8.19: Training photos by age group */
.training-age-group {
  width: 100%;
}

.training-age-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 8px;
  padding-left: 4px;
}

.training-photos-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.training-photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #e5e7eb;
}

.training-photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.training-photo-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.training-photo-item:hover .training-photo-delete,
.training-photo-item:active .training-photo-delete {
  opacity: 1;
}

/* Always show delete on touch devices */
@media (hover: none) {
  .training-photo-delete {
    opacity: 1;
  }
}

/* Crop Section */
.fm-crop-section {
  width: 100%;
  background: white;
  border-radius: 16px;
  padding: 20px;
  margin-top: 20px;
}

.fm-crop-container {
  width: 100%;
  max-height: 300px;
  overflow: hidden;
  border-radius: 12px;
  margin-bottom: 16px;
}

.fm-crop-container img {
  max-width: 100%;
}

.fm-crop-actions {
  display: flex;
  gap: 12px;
}

.fm-crop-confirm {
  flex: 2;
  padding: 14px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.fm-crop-cancel {
  flex: 1;
  padding: 14px;
  background: #f3f4f6;
  color: #4b5563;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

/* ======================= VOICE TRAINING ======================= */

.fm-voice-record-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 40px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
  transition: all 0.2s;
}

.fm-voice-record-btn:active {
  transform: scale(0.98);
}

.fm-voice-record-btn.recording {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
  animation: pulse-recording 1.5s infinite;
}

@keyframes pulse-recording {
  0%, 100% { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 4px 30px rgba(239, 68, 68, 0.6); }
}

.fm-record-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fm-record-text {
  font-size: 1rem;
  font-weight: 600;
}

/* Waveform */
.fm-waveform {
  width: 100%;
  max-width: 300px;
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin: 20px 0;
  text-align: center;
}

.fm-recording-time {
  display: block;
  font-size: 1.25rem;
  font-weight: 600;
  color: #ef4444;
  margin-top: 8px;
}

/* Voice Samples */
.fm-voice-samples-section {
  width: 100%;
  margin-top: 24px;
}

.fm-voice-samples-list {
  background: white;
  border-radius: 16px;
  padding: 16px;
}

/* ======================= RELATIONSHIPS LIST ======================= */

.fm-relationships-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ======================= AI CHAT ======================= */

.fm-ai-chat {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

.fm-ai-chat-messages {
  background: white;
  border-radius: 16px;
  padding: 16px;
  min-height: 200px;
  max-height: 300px;
  overflow-y: auto;
}

.fm-ai-chat-input {
  display: flex;
  gap: 8px;
}

.fm-ai-chat-input input {
  flex: 1;
  padding: 14px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 1rem;
}

.fm-ai-chat-input button {
  padding: 14px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ======================= RESPONSIVE ADJUSTMENTS ======================= */

/* v4.9.x: Compact centered modal on ALL devices - no full-screen overrides */
/* The .fm-modal base styles handle sizing; panels expand within the modal */

@media (min-width: 768px) {
  .fm-hero {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 30%, #f8f9fa 30%);
  }

  .fm-actions-grid {
    padding: 0 20px 24px;
  }

  .fm-action-card {
    padding: 14px 16px;
  }

  /* Panel content stays compact within modal */
  .fm-panel-content {
    padding: 20px 24px;
  }
}

/* ======================= DOCUMENTS & PHOTOS BUTTON ======================= */

.fm-docs-photos-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100% - 32px);
  margin: 16px 16px 8px;
  padding: 14px 16px;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.fm-docs-photos-btn:active {
  transform: scale(0.98);
  border-color: #14b8a6;
  background: #f0fdfa;
}

.fm-docs-photos-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
  color: #0d9488;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fm-docs-photos-label {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
}

.fm-docs-photos-count {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  min-width: 28px;
  text-align: center;
}

.fm-docs-photos-arrow {
  color: #9ca3af;
  flex-shrink: 0;
}

/* ======================= DOCUMENTS & PHOTOS PANEL ======================= */

.fm-panel-header-teal {
  background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
}

/* v4.9.0: Amber header for Stories panel */
.fm-panel-header-amber {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* v4.9.0: Stories Panel Styles */
.fm-stories-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.fm-stories-empty-icon {
  color: #d97706;
  margin-bottom: 16px;
}

.fm-stories-empty h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 8px;
}

.fm-stories-empty p {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0 0 24px;
  max-width: 280px;
}

.fm-add-first-story-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fm-add-first-story-btn:active {
  transform: scale(0.96);
}

.fm-stories-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.fm-story-card {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fm-story-card:active {
  transform: scale(0.98);
}

.fm-story-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #d97706;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.5rem;
}

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

.fm-story-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fm-story-meta {
  font-size: 0.8125rem;
  color: #6b7280;
}

.fm-story-arrow {
  color: #9ca3af;
  align-self: center;
}

.fm-panel-subtitle {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0 0 20px;
  padding: 0 4px;
}

/* Empty State */
.fm-docs-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 24px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.fm-docs-empty-icon {
  color: #d1d5db;
  margin-bottom: 16px;
}

.fm-docs-empty h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 8px;
}

.fm-docs-empty p {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0 0 20px;
}

.fm-add-first-doc-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.fm-add-first-doc-btn:active {
  transform: scale(0.98);
}

/* Documents List - v4.6.43: Mobile-first 2-column grid */
.fm-docs-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.fm-doc-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  border-top: 3px solid;
  border-left: none !important;
}

/* v4.6.43: Small thumbnails on mobile (2-column layout) */
.fm-doc-thumbnail {
  width: 100%;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  background: #f3f4f6;
  flex-shrink: 0;
}

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

/* v4.6.43: Compact title for mobile 2-column grid */
.fm-doc-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* v4.6.43: Compact meta for mobile */
.fm-doc-meta {
  font-size: 0.7rem;
  color: #6b7280;
  margin: 0 0 6px;
}

.fm-doc-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* v4.6.43: Compact buttons for mobile 2-column grid */
.fm-doc-action-btn {
  padding: 5px 10px;
  font-size: 0.7rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.fm-doc-action-btn.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.fm-doc-action-btn.secondary {
  background: #f3f4f6;
  color: #4b5563;
}

.fm-doc-action-btn.danger {
  background: #fee2e2;
  color: #dc2626;
}

.fm-doc-action-btn:active {
  transform: scale(0.95);
}

/* v4.6.39: Enhanced documents list for tablet/desktop */
.fm-doc-description {
  font-size: 0.8rem;
  color: #4b5563;
  margin: 4px 0;
  line-height: 1.4;
  display: none; /* Hidden on mobile */
}

.fm-doc-date {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 2px;
}

.fm-doc-thumbnail-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

/* v4.6.42: Override for tablet+ to show full photo instead of cropped strip */
@media (min-width: 768px) {
  .fm-doc-thumbnail-img {
    object-fit: contain;
    background: #f9fafb;
  }
}

/* v4.6.44: Tablet (768px+): 3 equal-width columns */
@media (min-width: 768px) {
  .fm-docs-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    width: 100%;
  }

  .fm-doc-item {
    padding: 14px;
    border-top: 4px solid;
    min-width: 0; /* Prevent content from expanding column */
    width: 100%;
  }

  .fm-doc-thumbnail {
    height: 140px;
    border-radius: 10px;
    margin-bottom: 10px;
  }

  .fm-doc-info {
    width: 100%;
  }

  .fm-doc-title {
    font-size: 0.95rem;
    white-space: normal;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .fm-doc-description {
    display: block;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .fm-doc-meta {
    font-size: 0.8rem;
    margin: 8px 0 10px;
  }

  .fm-doc-actions {
    justify-content: flex-start;
    gap: 10px;
  }

  .fm-doc-action-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
  }
}

/* v4.6.43: Desktop (1024px+): Larger cards, still 3 columns */
@media (min-width: 1024px) {
  .fm-docs-list {
    gap: 20px;
  }

  .fm-doc-item {
    padding: 18px;
  }

  .fm-doc-thumbnail {
    height: 180px;
    border-radius: 12px;
  }

  .fm-doc-title {
    font-size: 1.05rem;
  }

  .fm-doc-description {
    font-size: 0.85rem;
    -webkit-line-clamp: 3;
  }
}

/* ======================= RELATIONSHIP CARDS (Updated) ======================= */

.fm-relationship-group {
  margin-bottom: 20px;
}

.fm-relationship-group-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 10px;
  padding: 0 4px;
}

.fm-relationship-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: white;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  margin-bottom: 8px;
  transition: all 0.2s;
}

.fm-relationship-card-clickable {
  cursor: pointer;
}

.fm-relationship-card-clickable:active {
  transform: scale(0.98);
  background: #f9fafb;
}

.fm-rel-photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6366f1;
  flex-shrink: 0;
}

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

.fm-rel-name {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fm-rel-type {
  font-size: 0.8125rem;
  color: #6b7280;
  margin: 0;
}

.fm-rel-arrow {
  color: #9ca3af;
  flex-shrink: 0;
}

/* Safe Delete Button (not a trash can - uses text to prevent mistakes) */
.fm-rel-remove-btn {
  padding: 8px 12px;
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.fm-rel-remove-btn:hover {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #dc2626;
}

.fm-rel-remove-btn:active {
  transform: scale(0.95);
}

/* Confirmation state for delete */
.fm-rel-remove-btn.confirm {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
  animation: pulse-danger 1s infinite;
}

@keyframes pulse-danger {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

/* ============================================================================
   LEADERBOARD STYLES
   Gamification UI for family contributions
   ============================================================================ */

/* Period Toggle */
.leaderboard-period-toggle {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.period-btn {
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  background: white;
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

.period-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.period-btn.active {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-color: #f59e0b;
  color: white;
}

/* Family Goal Card */
.family-goal-card {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: var(--radius-xl);
  padding: 20px;
  margin: 20px 0;
  border: 1px solid #f59e0b;
}

.goal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.goal-icon {
  font-size: 1.5rem;
}

.goal-title {
  font-weight: 600;
  color: #92400e;
  font-size: var(--font-lg);
}

.goal-progress-bar {
  height: 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 8px;
}

.goal-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.goal-stats {
  text-align: center;
  font-weight: 600;
  color: #92400e;
}

/* Leaderboard List */
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
}

.leader-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  transition: all 0.2s;
}

.leader-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Top 3 special styling */
.leader-card.rank-1 {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #f59e0b;
}

.leader-card.rank-2 {
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  border-color: #9ca3af;
}

.leader-card.rank-3 {
  background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
  border-color: #ea580c;
}

.leader-rank {
  font-size: 1.75rem;
  width: 48px;
  text-align: center;
  flex-shrink: 0;
}

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

.leader-name {
  font-weight: 600;
  font-size: var(--font-lg);
  color: var(--color-text);
  margin-bottom: 4px;
}

.leader-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: var(--font-xs);
  color: var(--color-text-light);
}

.leader-breakdown span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.leader-points {
  text-align: right;
  flex-shrink: 0;
}

.leader-points-value {
  font-size: var(--font-xl);
  font-weight: 700;
  color: #f59e0b;
}

.leader-points-label {
  font-size: var(--font-xs);
  color: var(--color-text-light);
}

.leader-docs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-sm);
  color: #3b82f6;
  margin-top: 4px;
}

.leader-streak {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-sm);
  color: #ea580c;
  margin-top: 4px;
}

/* Your Stats Card */
.your-stats-card {
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
  border: 2px solid #8b5cf6;
  border-radius: var(--radius-xl);
  padding: 20px;
  margin: 20px 0;
}

.your-stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.your-stats-title {
  font-weight: 600;
  color: #5b21b6;
  font-size: var(--font-lg);
}

.your-stats-rank {
  background: #8b5cf6;
  color: white;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  font-weight: 600;
}

.your-stats-points {
  text-align: center;
  margin-bottom: 16px;
}

.your-stats-points .points-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: #5b21b6;
  display: block;
}

.your-stats-points .points-label {
  font-size: var(--font-sm);
  color: #7c3aed;
}

.your-stats-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.your-stat-item {
  text-align: center;
  padding: 12px;
  background: white;
  border-radius: var(--radius-lg);
}

.your-stat-item .stat-icon {
  font-size: 1.25rem;
  display: block;
  margin-bottom: 4px;
}

.your-stat-item .stat-count {
  font-weight: 700;
  color: #5b21b6;
}

.your-stat-item .stat-label {
  font-size: var(--font-xs);
  color: var(--color-text-light);
}

.your-stats-streak {
  text-align: center;
  font-size: var(--font-lg);
  color: #7c3aed;
  font-weight: 600;
}

.your-stats-streak .streak-icon {
  font-size: 1.5rem;
  margin-right: 8px;
}

/* Points Info Card */
.points-info-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: 20px;
  border: 1px solid var(--color-border);
  margin: 20px 0;
}

.points-info-card h3 {
  margin: 0 0 16px 0;
  color: var(--color-text);
  font-size: var(--font-lg);
}

.points-types {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.point-type {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
}

.point-icon {
  font-size: 1.25rem;
  width: 32px;
  text-align: center;
}

.point-name {
  flex: 1;
  font-weight: 500;
  color: var(--color-text);
}

.point-value {
  font-weight: 700;
  color: #10b981;
}

/* Loading indicator for leaderboard */
.leaderboard-list .loading-indicator {
  text-align: center;
  padding: 40px;
  color: var(--color-text-light);
}

/* Empty state */
.leaderboard-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-light);
}

.leaderboard-empty .empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.leaderboard-empty h3 {
  color: var(--color-text);
  margin-bottom: 8px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .leaderboard-period-toggle {
    flex-wrap: wrap;
    justify-content: center;
  }

  .leader-card {
    flex-wrap: wrap;
  }

  .leader-rank {
    width: 40px;
    font-size: 1.5rem;
  }

  .leader-info {
    flex: 1 1 calc(100% - 120px);
  }

  .leader-points {
    margin-left: auto;
  }

  .your-stats-breakdown {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================================
   Review Queue Styles
   ============================================================================ */

/* Review Queue Header */
.review-queue-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.review-filter-toggle {
  display: flex;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  padding: 4px;
  gap: 4px;
}

.filter-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background: var(--color-bg-tertiary);
}

.filter-btn.active {
  background: var(--color-primary);
  color: white;
}

/* Review Stats Bar */
.review-stats-bar {
  display: flex;
  justify-content: space-around;
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.review-stat {
  text-align: center;
}

.review-stat .stat-number {
  display: block;
  font-size: var(--font-2xl);
  font-weight: var(--font-bold);
  color: var(--color-primary);
}

.review-stat .stat-label {
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

/* Bulk Action Bar */
.bulk-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
}

.bulk-select-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: var(--font-medium);
}

.bulk-select-info input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.bulk-buttons {
  display: flex;
  gap: var(--space-sm);
}

/* Review Queue Grid */
.review-queue-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Review Item Card */
.review-item-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.review-item-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.review-item-select {
  flex-shrink: 0;
}

.review-item-select input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.review-item-thumb {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-secondary);
  cursor: pointer;
}

.review-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.review-item-name {
  font-weight: var(--font-semibold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: var(--space-xs);
}

.review-item-meta {
  display: flex;
  gap: var(--space-md);
  font-size: var(--font-xs);
  color: var(--color-text-light);
  flex-wrap: wrap;
}

.review-item-ai {
  font-size: var(--font-sm);
  color: var(--color-text-light);
  margin-top: var(--space-xs);
  font-style: italic;
}

.review-item-faces {
  font-size: var(--font-sm);
  color: var(--color-success);
  margin-top: var(--space-xs);
}

.review-item-actions {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: var(--font-medium);
  margin-top: var(--space-xs);
}

.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.status-processing {
  background: #dbeafe;
  color: #1e40af;
}

.status-ready {
  background: #d1fae5;
  color: #065f46;
}

.status-approved {
  background: #d1fae5;
  color: #065f46;
}

.status-rejected {
  background: #fee2e2;
  color: #991b1b;
}

/* Review Empty State */
.review-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
}

.review-empty .empty-icon {
  font-size: 4rem;
  margin-bottom: var(--space-lg);
}

.review-empty h3 {
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.review-empty p {
  color: var(--color-text-light);
  margin-bottom: var(--space-lg);
}

.review-error {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--color-text-light);
}

.review-error button {
  margin-top: var(--space-md);
}

/* AI Analysis Tags */
.ai-tag {
  display: inline-block;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: var(--font-medium);
  margin: 2px;
}

.fm-ai-message {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.fm-ai-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.fm-ai-content {
  flex: 1;
  background: var(--color-bg-secondary);
  padding: var(--space-md);
  border-radius: var(--radius-lg);
}

.fm-ai-content p {
  margin-bottom: var(--space-sm);
}

.fm-ai-content p:last-child {
  margin-bottom: 0;
}

/* Face Detection Preview Styles */
.face-detection-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.face-detection-results {
  margin-top: var(--space-md);
}

.face-warning {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: #fef3c7;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-sm);
}

.face-warning.error {
  background: #fee2e2;
}

.face-warning .warning-icon {
  font-size: 1.5rem;
}

.face-warning .warning-text {
  flex: 1;
  color: #92400e;
  font-weight: var(--font-medium);
}

.face-warning.error .warning-text {
  color: #991b1b;
}

.face-detection-success {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: #d1fae5;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-sm);
}

.face-detection-success .success-icon {
  font-size: 1.5rem;
}

.face-detection-success .success-text {
  flex: 1;
  color: #065f46;
  font-weight: var(--font-medium);
}

.face-detection-success .quality-badge {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  color: white;
  font-size: var(--font-sm);
  font-weight: var(--font-semibold);
}

.face-recommendation {
  padding: var(--space-sm);
  margin: 0;
  font-size: var(--font-sm);
  text-align: center;
}

.face-recommendation.good {
  color: #065f46;
}

.face-recommendation.warning {
  color: #92400e;
}

.face-recommendation.error {
  color: #991b1b;
}

/* Canvas overlay for bounding boxes */
.face-bbox-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Ensure parent container is positioned for canvas overlay */
.fm-crop-image-container,
.training-photos-crop-image-container {
  position: relative;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .review-queue-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .review-filter-toggle {
    justify-content: center;
  }

  .review-stats-bar {
    flex-direction: column;
    gap: var(--space-md);
  }

  .bulk-action-bar {
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }

  .review-item-card {
    flex-wrap: wrap;
  }

  .review-item-thumb {
    width: 60px;
    height: 60px;
  }

  .review-item-info {
    flex-basis: calc(100% - 100px);
  }

  .review-item-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--color-border);
  }
}

/* ============================================================================
   Photo Source Selection Modal (v3.8.20)
   ============================================================================ */

.photo-source-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10000;
  padding: 0;
}

.photo-source-modal {
  background: var(--color-bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 500px;
  padding: var(--space-lg);
  padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
  animation: slideUpModal 0.3s ease-out;
}

@keyframes slideUpModal {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.photo-source-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  margin: 0 0 var(--space-lg) 0;
}

.photo-source-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.photo-source-btn {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.photo-source-btn:hover,
.photo-source-btn:focus {
  background: var(--color-bg-tertiary);
  border-color: var(--color-primary);
}

.photo-source-btn:active {
  transform: scale(0.98);
}

.photo-source-icon {
  font-size: 2rem;
  flex-shrink: 0;
  width: 50px;
  text-align: center;
}

.photo-source-label {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--color-text);
  display: block;
}

.photo-source-desc {
  font-size: var(--font-sm);
  color: var(--color-text-light);
  display: block;
  margin-top: 2px;
}

.photo-source-cancel {
  display: block;
  width: 100%;
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: transparent;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--font-base);
  font-weight: 500;
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 0.2s ease;
}

.photo-source-cancel:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-text-light);
}

/* Desktop adjustments */
@media (min-width: 768px) {
  .photo-source-modal-overlay {
    align-items: center;
  }

  .photo-source-modal {
    border-radius: var(--radius-xl);
    margin: var(--space-lg);
    padding-bottom: var(--space-lg);
  }

  .photo-source-options {
    flex-direction: row;
    gap: var(--space-md);
  }

  .photo-source-btn {
    flex-direction: column;
    text-align: center;
    padding: var(--space-lg);
    flex: 1;
  }

  .photo-source-icon {
    width: auto;
    font-size: 2.5rem;
    margin-bottom: var(--space-sm);
  }
}

/* ============================================================================
   Login / Authentication Styles (v4.1.0)
   ============================================================================ */

/* Hidden state for main UI when showing login */
.top-nav.hidden,
.side-nav.hidden,
.main-content.hidden {
  display: none !important;
}

/* Login Overlay */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: var(--space-md);
}

.login-container {
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: var(--space-xl);
  animation: slideUp 0.3s ease-out;
}

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

.login-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.login-logo {
  max-width: 200px;
  height: auto;
  margin-bottom: var(--space-md);
}

.login-header h1 {
  font-size: var(--font-2xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.login-header p {
  color: var(--color-text-light);
  font-size: var(--font-sm);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.login-form h3 {
  font-size: var(--font-xl);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.login-form .form-description {
  font-size: var(--font-sm);
  color: var(--color-text-light);
  margin-bottom: var(--space-md);
}

.login-form .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.login-form label {
  font-size: var(--font-sm);
  font-weight: var(--font-medium);
  color: var(--color-text);
}

.login-form input[type="email"],
.login-form input[type="password"],
.login-form input[type="text"] {
  width: 100%;
  padding: var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-base);
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.login-error {
  color: var(--color-danger);
  font-size: var(--font-sm);
  min-height: 1.25rem;
}

.login-btn {
  width: 100%;
  padding: var(--space-md);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-base);
  font-weight: var(--font-semibold);
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.login-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.login-btn:active:not(:disabled) {
  transform: translateY(0);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.forgot-password,
.back-to-login {
  display: block;
  text-align: center;
  font-size: var(--font-sm);
  color: var(--color-text-light);
  margin-top: var(--space-md);
}

.forgot-password:hover,
.back-to-login:hover {
  color: var(--color-primary);
}

/* Secret Questions Setup */
.question-item {
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
}

.question-checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: var(--font-sm);
  line-height: 1.4;
}

.question-checkbox input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
}

.question-answer {
  margin-top: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
  font-family: inherit;
}

.question-answer:focus {
  outline: none;
  border-color: var(--color-primary);
}

.questions-counter {
  font-size: var(--font-sm);
  color: var(--color-text-light);
  text-align: center;
  margin: var(--space-md) 0;
}

/* Form hints for account setup */
.form-hint {
  display: block;
  font-size: var(--font-xs);
  color: var(--color-text-light);
  margin-top: var(--space-xs);
}

/* Account setup form specific */
#accountSetupForm h4 {
  margin-top: var(--space-md);
  margin-bottom: var(--space-sm);
  color: var(--color-text);
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .login-container {
    padding: var(--space-lg);
  }

  .login-header h1 {
    font-size: var(--font-xl);
  }
}

/* v4.6.5 - AI Document Analysis modal full width overlay */
@media (min-width: 768px) {
  .ai-modal-fullscreen {
    width: 100vw;
    max-width: none;
    left: 0;
    transform: none;
  }
}

/* v4.6.7 - Compact header for AI Document Analysis modal (Mac Safari) */
.ai-modal-header-compact {
  padding: 8px var(--space-lg);
  justify-content: center;
}

.ai-modal-header-compact .ai-modal-title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* v4.6.8 - Rejection modal must appear above AI modal */
#rejectionReasonModal {
  z-index: 25000;
}

#rejectionReasonModal .modal-overlay {
  z-index: 24999;
}

#rejectionReasonModal .modal-dialog {
  z-index: 25001;
}

/* ============================================================================
   v4.6.25 - iPad/Tablet Specific Styles (768px - 1024px)
   ============================================================================ */

@media (min-width: 768px) and (max-width: 1024px) {
  /* AI Modal - centered on tablet instead of full-screen */
  .ai-modal-fullscreen {
    top: 5vh;
    left: 5vw;
    right: 5vw;
    bottom: 5vh;
    width: 90vw;
    max-width: none;
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  }

  /* Family member modal - compact centered on all devices */
  .family-member-modal {
    max-width: 420px;
  }

  .fm-modal {
    /* Keep compact - same as base (420px) */
    max-width: 420px;
  }

  /* Document duplicate dialog - comfortable width */
  #duplicateDocumentOverlay > div {
    max-width: 450px;
  }

  /* Larger touch targets for buttons */
  .ai-save-btn,
  .btn-primary-mobile {
    min-height: 48px;
    font-size: 1rem;
  }

  /* Footer action buttons - comfortable spacing */
  .ai-modal-footer {
    padding: 12px 16px;
  }

  /* Filename input - ensure adequate size */
  #aiFilenameInput {
    font-size: 0.85rem;
    padding: 6px 8px;
  }

  /* Navigation - show full names */
  .nav-title {
    font-size: 1.1rem;
  }

  /* Tree panel - wider on tablet */
  .tree-nav-panel {
    width: 300px;
  }

  /* Photo grid - 3 columns on tablet */
  .training-photos-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Documents grid - 2 columns */
  .documents-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================================
   Leaderboard Hero Screen (v4.5.0)
   Full-screen overlay shown on app launch
   ============================================================================ */

.leaderboard-hero-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  z-index: 10001;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.leaderboard-hero-overlay.hero-visible {
  opacity: 1;
}

.leaderboard-hero-overlay.hero-hiding {
  opacity: 0;
  pointer-events: none; /* v5.0.5: Ensure clicks pass through to modal below */
}

.hero-container {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: heroSlideUp 0.4s ease-out;
}

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

/* Hero Header */
.hero-header {
  text-align: center;
  padding: 10px 0;
}

.hero-greeting {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 8px 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.hero-subtitle {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.8);
  margin: 0;
}

.hero-version {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 6px;
  font-weight: 500;
}

/* Hero Goal Card */
.hero-goal-card {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.hero-goal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.hero-goal-icon {
  font-size: 1.5rem;
}

.hero-goal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}

.hero-goal-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hero-goal-bar {
  height: 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  overflow: hidden;
}

.hero-goal-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: 6px;
  transition: width 0.5s ease;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.hero-goal-stats {
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
}

/* Hero Podium */
.hero-podium {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hero-podium-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
  text-align: center;
  margin: 0;
}

.hero-podium-ranks {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero-rank-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: transform 0.2s ease;
}

.hero-rank-card.gold {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.25), rgba(255, 184, 0, 0.15));
  border-color: rgba(255, 215, 0, 0.4);
}

.hero-rank-card.silver {
  background: linear-gradient(135deg, rgba(192, 192, 192, 0.25), rgba(169, 169, 169, 0.15));
  border-color: rgba(192, 192, 192, 0.4);
}

.hero-rank-card.bronze {
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.25), rgba(180, 100, 40, 0.15));
  border-color: rgba(205, 127, 50, 0.4);
}

.hero-rank-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.hero-rank-info {
  flex: 1;
}

.hero-rank-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.hero-rank-points {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.8);
}

.hero-rank-streak {
  font-size: 0.85rem;
  color: #fbbf24;
  margin-top: 4px;
}

/* Your Rank (if not in top 3) */
.hero-your-rank {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hero-your-rank-label {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
}

.hero-your-rank-value {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-your-rank-position {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}

.hero-your-rank-points {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
}

/* Continue Button */
.hero-continue-btn {
  width: 100%;
  padding: 18px 24px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #1e1b4b;
  background: linear-gradient(135deg, #fff 0%, #f0f0f0 100%);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  margin-top: 10px;
}

.hero-continue-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.hero-continue-btn:active {
  transform: translateY(0);
}

/* Loading/Error states */
.hero-loading,
.hero-error,
.hero-empty {
  text-align: center;
  padding: 20px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
}

/* Tablet adjustments */
@media (min-width: 768px) {
  .hero-container {
    max-width: 550px;
    padding: 20px;
  }

  .hero-greeting {
    font-size: 2rem;
  }

  .hero-rank-card {
    padding: 18px 20px;
  }
}

/* Desktop adjustments */
@media (min-width: 1024px) {
  .hero-container {
    max-width: 600px;
  }

  .hero-greeting {
    font-size: 2.25rem;
  }

  /* Horizontal layout for podium on desktop */
  .hero-podium-ranks {
    flex-direction: row;
    gap: 12px;
  }

  .hero-rank-card {
    flex: 1;
    flex-direction: column;
    text-align: center;
    padding: 20px 16px;
  }

  .hero-rank-info {
    text-align: center;
  }
}

/* ============================================================================
   Archive Chat Interface (v4.5.0)
   Collapsible chat for natural language queries
   ============================================================================ */

.archive-chat-container {
  margin-bottom: 16px;
}

/* Collapsed State */
.archive-chat-collapsed {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  border-radius: 12px;
  border: 1px solid #d1d5db;
  cursor: pointer;
  transition: all 0.2s ease;
}

.archive-chat-collapsed:hover {
  background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
  border-color: #9ca3af;
}

.archive-chat-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.archive-chat-input-collapsed {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  color: #374151;
  outline: none;
}

.archive-chat-input-collapsed::placeholder {
  color: #9ca3af;
}

.archive-chat-voice-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.archive-chat-voice-btn:hover {
  transform: scale(1.05);
}

/* Expanded State */
.archive-chat-expanded {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  max-height: 400px;
}

.archive-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
}

.archive-chat-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.archive-chat-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.archive-chat-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Messages Area */
.archive-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 150px;
  max-height: 250px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.archive-chat-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.archive-chat-message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.archive-chat-message.assistant {
  align-self: flex-start;
  background: #f3f4f6;
  color: #1f2937;
  border-bottom-left-radius: 4px;
}

.archive-chat-message-text strong {
  font-weight: 600;
}

/* Inline Content */
.archive-chat-inline-content {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.archive-chat-inline-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 70px;
}

.archive-chat-inline-item:hover {
  border-color: #6366f1;
  transform: translateY(-2px);
}

.archive-chat-inline-thumb {
  font-size: 1.5rem;
}

.archive-chat-inline-caption {
  font-size: 0.7rem;
  color: #6b7280;
  text-align: center;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-chat-more {
  font-size: 0.8rem;
  color: #6366f1;
  margin-top: 6px;
  cursor: pointer;
}

/* Loading State */
.archive-chat-loading {
  padding: 10px;
  text-align: center;
  color: #9ca3af;
  font-size: 0.85rem;
}

.loading-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* Input Area */
.archive-chat-input-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

.archive-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.archive-chat-input:focus {
  border-color: #6366f1;
}

.archive-chat-send-btn {
  padding: 10px 18px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.archive-chat-send-btn:hover {
  transform: scale(1.02);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .archive-chat-expanded {
    max-height: 60vh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .archive-chat-messages {
    max-height: calc(60vh - 120px);
  }

  .archive-chat-message {
    max-width: 90%;
  }

  .archive-chat-inline-content {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  .archive-chat-inline-item {
    flex-shrink: 0;
  }
}

/* ============================================================================
   STORIES VIEW - v4.8.0
   ============================================================================ */

/* Stories Header */
.stories-header {
  flex-wrap: wrap;
  gap: var(--space-md);
}

.stories-title-section h2 {
  margin: 0;
  font-size: var(--font-2xl);
}

.stories-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* View Mode Buttons */
.stories-view-modes {
  display: flex;
  gap: var(--space-xs);
  background: var(--color-bg-secondary);
  padding: var(--space-xs);
  border-radius: var(--radius-lg);
}

.stories-view-mode-btn {
  padding: var(--space-sm) var(--space-md);
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-sm);
  color: var(--color-text-light);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.stories-view-mode-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.stories-view-mode-btn.active {
  background: var(--color-primary);
  color: white;
}

/* Filters */
.stories-filters {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.stories-filters .select-input {
  min-width: 150px;
}

/* Stories Container */
.stories-container {
  padding: var(--space-lg);
  min-height: 400px;
}

.stories-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--color-text-light);
  font-size: var(--font-lg);
}

.stories-empty {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--color-text-light);
}

/* Timeline Mode */
.stories-timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Narratives Mode */
.stories-narratives {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.story-arc-group {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.story-arc-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.story-arc-icon {
  font-size: var(--font-2xl);
}

.story-arc-title {
  margin: 0;
  font-size: var(--font-xl);
  flex: 1;
}

.story-arc-count {
  font-size: var(--font-sm);
  opacity: 0.9;
}

.story-arc-stories {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* Gallery Mode */
.stories-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-lg);
}

.story-gallery-card {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.story-gallery-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.story-gallery-thumb {
  aspect-ratio: 16/9;
  background: var(--color-bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-thumb-placeholder {
  font-size: 3rem;
}

.story-gallery-info {
  padding: var(--space-md);
}

.story-gallery-info h4 {
  margin: 0 0 var(--space-xs) 0;
  font-size: var(--font-base);
  color: var(--color-text);
}

.story-gallery-dates {
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

/* Story Card */
.story-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.story-card:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-primary);
}

.story-card.compact {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
}

.story-card-icon {
  font-size: var(--font-2xl);
  flex-shrink: 0;
}

.story-card-content {
  flex: 1;
  min-width: 0;
}

.story-card-title {
  margin: 0;
  font-size: var(--font-lg);
  color: var(--color-text);
}

.compact .story-card-title {
  font-size: var(--font-base);
}

.story-card-subtitle {
  margin: var(--space-xs) 0 0 0;
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.story-card-meta {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-xs);
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.story-card-meta span {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.story-card-persons {
  margin-top: var(--space-xs);
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.persons-label {
  font-weight: 500;
}

.story-card-arrow {
  font-size: var(--font-lg);
  color: var(--color-text-lighter);
  flex-shrink: 0;
}

/* Story Detail Modal */
.story-detail-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-bg);
  z-index: 1000;
  overflow-y: auto;
  display: none;
}

.story-detail-modal.active {
  display: block;
}

.story-modal-header {
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: var(--space-lg);
  z-index: 10;
}

.story-modal-header h2 {
  margin: 0;
  font-size: var(--font-2xl);
}

.story-modal-subtitle {
  margin: var(--space-xs) 0 0 0;
  opacity: 0.9;
}

.btn-close-story-modal {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255,255,255,0.2);
  color: white;
  border-radius: 50%;
  font-size: var(--font-xl);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-story-modal:hover {
  background: rgba(255,255,255,0.3);
}

.story-modal-content {
  padding: var(--space-lg);
  max-width: 800px;
  margin: 0 auto;
}

.story-modal-meta {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

/* Watch Full Video Button */
.story-watch-full-video {
  margin-bottom: var(--space-lg);
  text-align: center;
}

.btn-watch-full-video {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  background: linear-gradient(135deg, var(--color-primary), #4f46e5);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--font-md);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-watch-full-video:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.btn-watch-full-video:active {
  transform: translateY(0);
}

/* Full Story Video Player Modal */
#fullStoryVideoPlayer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#fullStoryVideoPlayer .video-player-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10001;
}

#fullStoryVideoPlayer video {
  max-width: 95vw;
  max-height: 85vh;
  border-radius: var(--radius-md);
}

/* Event Photo Gallery Modal (v4.9.4) */
.event-photo-gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: none;
}

.event-photo-gallery-modal.active {
  display: block;
}

.event-gallery-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
}

.event-gallery-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.event-gallery-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10001;
}

.event-gallery-main {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-height: 70vh;
}

.event-gallery-nav {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 2rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.event-gallery-nav:hover {
  background: rgba(255, 255, 255, 0.3);
}

.event-gallery-image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 var(--space-md);
  max-height: 100%;
}

.event-gallery-image-container img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.event-gallery-counter {
  color: white;
  font-size: var(--font-md);
  margin: var(--space-md) 0;
}

.event-gallery-thumbnails {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding: var(--space-sm);
  max-width: 100%;
}

.event-gallery-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  background-size: cover;
  background-position: center;
  cursor: pointer;
  border: 2px solid transparent;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.2s, border-color 0.2s;
}

.event-gallery-thumb:hover {
  opacity: 0.8;
}

.event-gallery-thumb.active {
  opacity: 1;
  border-color: white;
}

/* Mobile adjustments for gallery */
@media (max-width: 767px) {
  .event-gallery-nav {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }

  .event-gallery-thumb {
    width: 50px;
    height: 50px;
  }
}

/* Watch hint under Watch Full Video button */
.watch-hint {
  margin-top: var(--space-sm);
  font-size: var(--font-xs);
  color: var(--color-text-light);
}

.story-modal-description,
.story-modal-persons,
.story-modal-chapters,
.story-modal-contributions {
  margin-bottom: var(--space-xl);
}

.story-modal-description h3,
.story-modal-persons h3,
.story-modal-chapters h3,
.story-modal-contributions h3 {
  margin: 0 0 var(--space-md) 0;
  font-size: var(--font-lg);
  color: var(--color-text);
}

.story-persons-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.story-person-tag {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  color: var(--color-text);
  cursor: pointer;
}

.story-person-tag:hover {
  background: var(--color-primary);
  color: white;
}

.story-chapter-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  align-items: center;
}

.story-chapter-item:hover {
  background: var(--color-bg-tertiary, #e5e7eb);
  transform: translateX(4px);
}

.story-chapter-item.expanded {
  background: var(--color-primary-light, #e0e7ff);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0;
}

.chapter-expand-icon {
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-left: auto;
  transition: transform 0.2s;
}

.story-chapter-item.expanded .chapter-expand-icon {
  transform: rotate(90deg);
}

/* v4.9.0: Chapter media containers */
.chapter-media-container {
  background: var(--color-bg-tertiary, #f3f4f6);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  border-left: 3px solid var(--color-primary);
}

.chapter-media-loading,
.chapter-media-empty,
.chapter-media-error {
  text-align: center;
  padding: var(--space-lg);
  color: var(--color-text-light);
  font-size: var(--font-sm);
}

.chapter-media-error {
  color: var(--color-error, #ef4444);
}

.chapter-media-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.chapter-video-wrapper {
  width: 100%;
}

.chapter-video-wrapper video {
  width: 100%;
  border-radius: var(--radius-md);
  background: #000;
  max-height: 400px;
}

.chapter-video-caption,
.chapter-image-caption {
  margin: var(--space-xs) 0 0;
  font-size: var(--font-sm);
  color: var(--color-text-light);
  text-align: center;
}

.chapter-image-wrapper {
  text-align: center;
}

.chapter-image-wrapper img {
  max-height: 300px;
  object-fit: contain;
}

.chapter-document-wrapper {
  padding: var(--space-sm);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-sm);
}

.chapter-document-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.chapter-document-link:hover {
  text-decoration: underline;
}

.chapter-number {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  font-weight: 600;
  flex-shrink: 0;
}

.chapter-info {
  flex: 1;
}

.chapter-info strong {
  display: block;
  margin-bottom: var(--space-xs);
}

.chapter-info p {
  margin: 0;
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

/* v4.9.x: Story Events Section */
.story-modal-events {
  margin-bottom: var(--space-xl);
}

.story-modal-events h3 {
  margin: 0 0 var(--space-md) 0;
  font-size: var(--font-lg);
  color: var(--color-text);
}

.story-events-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.story-event-card {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  align-items: flex-start;
}

.story-event-card:hover {
  background: var(--color-bg-tertiary, #e5e7eb);
  transform: translateX(4px);
}

.story-event-card:active {
  transform: scale(0.98);
}

.event-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

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

.event-info strong {
  display: block;
  margin-bottom: var(--space-xs);
  color: var(--color-text);
}

.event-year {
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.event-description {
  margin: var(--space-xs) 0 0;
  font-size: var(--font-sm);
  color: var(--color-text-light);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event-play-icon {
  font-size: 1.25rem;
  color: var(--color-primary);
  flex-shrink: 0;
  opacity: 0.7;
}

.story-event-card:hover .event-play-icon {
  opacity: 1;
}

/* Event Video Player Modal */
.event-video-player-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20000;
  display: none;
  align-items: center;
  justify-content: center;
}

.event-video-player-modal.active {
  display: flex;
}

.event-video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
}

/* v5.2.6: Wrapper and close bar for Safari compatibility */
/* Safari's native video controls capture clicks, so close button must be OUTSIDE video area */
.event-video-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  width: 90vw;
}

.event-video-close-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.event-video-close-bar .video-title {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  font-weight: 500;
}

.event-video-close-btn {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  /* Ensure clickable on Safari */
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.event-video-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.event-video-close-btn:active {
  transform: scale(0.97);
  background: rgba(255, 255, 255, 0.3);
}

.event-video-container {
  position: relative;
  width: 100%;
  max-height: 80vh;
}

.event-video-container video {
  width: 100%;
  max-height: 75vh;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: #000;
  display: block;
}

/* Keep old close button styles for backwards compatibility but hide it */
.event-video-close {
  display: none;
}

.story-contribution {
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
}

.contribution-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.contributor-name {
  font-weight: 500;
  color: var(--color-text);
}

.contribution-type {
  font-size: var(--font-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-full);
  text-transform: capitalize;
}

.story-contribution p {
  margin: 0;
  color: var(--color-text);
}

.story-modal-stats {
  display: flex;
  gap: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-light);
  font-size: var(--font-sm);
}

/* Mobile Adjustments for Stories */
@media (max-width: 768px) {
  .stories-header {
    flex-direction: column;
    align-items: stretch;
  }

  .stories-controls {
    justify-content: center;
  }

  .stories-view-modes {
    width: 100%;
    justify-content: center;
  }

  .stories-filters {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .stories-filters .select-input {
    width: 100%;
  }

  .stories-gallery {
    grid-template-columns: repeat(2, 1fr);
  }

  .story-card {
    flex-wrap: wrap;
  }

  .story-card-arrow {
    display: none;
  }

  .story-modal-stats {
    flex-direction: column;
    gap: var(--space-sm);
  }
}

/* ============================================
   Contribution Bar & Modals (v5.0.6)
   ============================================ */

/* Contribution Bar - Fixed at bottom of story detail */
.contribution-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
  border-top: 1px solid var(--color-border);
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.contribution-bar-label {
  font-size: var(--font-sm);
  color: var(--color-text-light);
  font-weight: 500;
  text-align: center;
}

.contribution-bar-buttons {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
}

.contribution-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 70px;
}

.contribution-btn:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.contribution-btn:active {
  transform: translateY(0);
}

.contribution-btn .contribution-icon {
  font-size: 1.5rem;
}

.contribution-btn .contribution-label {
  font-size: var(--font-xs);
  color: var(--color-text-light);
  font-weight: 500;
}

.contribution-btn.voice:hover { border-color: #e74c3c; }
.contribution-btn.text:hover { border-color: #3498db; }
.contribution-btn.media:hover { border-color: #2ecc71; }

/* AI Dialogue Button - More prominent */
.contribution-btn-ai {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  width: 100%;
  margin-top: var(--space-xs);
}

.contribution-btn-ai:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.contribution-btn-ai:active {
  transform: translateY(0);
}

.contribution-btn-ai .contribution-icon {
  font-size: 1.2rem;
}

.contribution-btn-ai .contribution-label {
  font-size: var(--font-sm);
}

/* Contribution Modal Overlay */
.contribution-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: var(--space-md);
  animation: fadeIn 0.2s ease;
}

.contribution-modal {
  background: var(--color-bg-primary);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

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

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

.contribution-modal-header h3 {
  margin: 0;
  font-size: var(--font-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.contribution-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-text-light);
  cursor: pointer;
  padding: var(--space-xs);
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.contribution-modal-close:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text);
}

.contribution-modal-body {
  padding: var(--space-lg);
}

/* Voice Recording Area */
.voice-recording-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-xl) 0;
}

.voice-recording-indicator {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: white;
  transition: all 0.3s ease;
}

.voice-recording-indicator.recording {
  animation: pulse-recording 1.5s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.5);
}

@keyframes pulse-recording {
  0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.5); }
  70% { box-shadow: 0 0 0 20px rgba(231, 76, 60, 0); }
  100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

.voice-recording-timer {
  font-size: var(--font-xl);
  font-weight: 600;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.voice-recording-hint {
  font-size: var(--font-sm);
  color: var(--color-text-light);
  text-align: center;
}

.voice-recording-controls {
  display: flex;
  gap: var(--space-md);
  width: 100%;
  max-width: 300px;
}

.voice-btn {
  flex: 1;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.voice-btn-record {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  color: white;
  border: none;
}

.voice-btn-record:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.voice-btn-record.recording {
  background: linear-gradient(135deg, #f39c12 0%, #d68910 100%);
}

.voice-btn-submit {
  background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
  color: white;
  border: none;
}

.voice-btn-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

.voice-btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Text Input Area */
.text-input-area {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.text-input-area textarea {
  width: 100%;
  min-height: 150px;
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--font-base);
  resize: vertical;
  transition: border-color 0.2s ease;
}

.text-input-area textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.text-input-area textarea::placeholder {
  color: var(--color-text-lighter);
}

.text-input-submit {
  align-self: flex-end;
  padding: var(--space-sm) var(--space-lg);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.text-input-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.text-input-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Media Upload Area */
.media-upload-area {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.media-upload-options {
  display: flex;
  gap: var(--space-md);
}

.media-upload-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.media-upload-btn:hover {
  border-color: var(--color-primary);
  background: rgba(102, 126, 234, 0.05);
}

.media-upload-btn .upload-icon {
  font-size: 2rem;
}

.media-upload-btn .upload-label {
  font-size: var(--font-sm);
  color: var(--color-text-light);
  font-weight: 500;
}

.media-upload-preview {
  display: none;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
}

.media-upload-preview.has-file {
  display: flex;
}

.media-preview-image {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.media-preview-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.media-preview-name {
  font-size: var(--font-sm);
  color: var(--color-text);
  font-weight: 500;
}

.media-preview-remove {
  background: none;
  border: none;
  color: var(--color-danger);
  cursor: pointer;
  font-size: var(--font-sm);
  padding: var(--space-xs);
}

.media-caption-input {
  width: 100%;
  padding: var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--font-sm);
}

.media-caption-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.media-upload-submit {
  padding: var(--space-sm) var(--space-lg);
  background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.media-upload-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

.media-upload-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile responsiveness for contribution bar */
@media (max-width: 480px) {
  .contribution-bar {
    padding: var(--space-sm) var(--space-md);
  }

  .contribution-btn {
    min-width: 60px;
    padding: var(--space-xs) var(--space-sm);
  }

  .contribution-btn .contribution-icon {
    font-size: 1.2rem;
  }

  .contribution-btn .contribution-label {
    font-size: 10px;
  }

  .contribution-modal {
    max-height: 85vh;
  }

  .voice-recording-indicator {
    width: 100px;
    height: 100px;
    font-size: 2.5rem;
  }
}

/* ============================================
   Story Chat UI Styles (v4.8.1)
   ============================================ */

/* Tab Navigation */
.story-modal-tabs {
  display: flex;
  gap: 0;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 5;
}

.story-tab-btn {
  flex: 1;
  padding: var(--space-md) var(--space-lg);
  border: none;
  background: transparent;
  color: var(--color-text-light);
  font-size: var(--font-base);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 3px solid transparent;
  max-width: 200px;
}

.story-tab-btn:hover {
  color: var(--color-text);
  background: rgba(102, 126, 234, 0.05);
}

.story-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  background: rgba(102, 126, 234, 0.1);
}

/* Chat Container */
.story-chat-tab {
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 180px);
  max-height: 600px;
}

.story-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.story-chat-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.story-chat-header h3 {
  margin: 0 0 var(--space-xs) 0;
  font-size: var(--font-lg);
  color: var(--color-text);
}

.story-chat-hint {
  margin: 0;
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

/* Chat Messages Area */
.story-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  background: var(--color-bg-secondary);
}

/* Welcome Message */
.story-chat-welcome {
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-text-light);
}

.chat-welcome-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
}

.story-chat-welcome p {
  margin: var(--space-sm) 0;
}

.story-chat-welcome ul {
  text-align: left;
  display: inline-block;
  margin: var(--space-md) 0;
  padding-left: var(--space-lg);
}

.story-chat-welcome li {
  margin: var(--space-xs) 0;
  color: var(--color-text);
  font-style: italic;
}

/* Chat Messages */
.story-chat-message {
  display: flex;
  gap: var(--space-sm);
  max-width: 85%;
  animation: messageSlideIn 0.3s ease;
}

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

.story-chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.story-chat-message.assistant {
  align-self: flex-start;
}

.story-chat-message .message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.story-chat-message.user .message-avatar {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.story-chat-message .message-content {
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  line-height: 1.5;
  font-size: var(--font-base);
}

.story-chat-message.user .message-content {
  background: var(--color-primary);
  color: white;
  border-bottom-right-radius: var(--radius-sm);
}

.story-chat-message.assistant .message-content {
  background: var(--color-bg);
  color: var(--color-text);
  border-bottom-left-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-light);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Chat Input Area */
.story-chat-input-area {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
}

.story-chat-input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-base);
  font-family: inherit;
  resize: none;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 44px;
  max-height: 120px;
}

.story-chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.story-chat-input::placeholder {
  color: var(--color-text-light);
}

.story-chat-send-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.story-chat-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.story-chat-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.story-chat-send-btn .send-icon {
  font-size: 18px;
}

/* Mobile Adjustments for Story Chat */
@media (max-width: 768px) {
  .story-modal-tabs {
    padding: 0 var(--space-md);
  }

  .story-tab-btn {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-sm);
  }

  .story-chat-tab {
    height: calc(100vh - 200px);
  }

  .story-chat-message {
    max-width: 90%;
  }

  .story-chat-header {
    padding: var(--space-md);
  }

  .story-chat-messages {
    padding: var(--space-md);
  }

  .story-chat-input-area {
    padding: var(--space-sm) var(--space-md);
  }
}

/* ============================================================================
   v5.0.3 - Family Member Modal Compact Tiles for iPhone
   More aggressive compaction to fit all controls without scrolling
   ============================================================================ */

@media (max-width: 480px) {
  /* Tighter gap and padding in tile grid */
  .fm-tile-grid {
    gap: 6px;
    padding: 0 10px 12px;
  }

  /* Much smaller tiles - fit on one screen */
  .fm-tile {
    aspect-ratio: auto;
    min-height: 56px;
    padding: 8px 10px;
    border-radius: 10px;
  }

  /* Smaller icons */
  .fm-tile-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    margin-bottom: 4px;
  }

  .fm-tile-icon svg {
    width: 20px;
    height: 20px;
  }

  /* Smaller label text */
  .fm-tile-label {
    font-size: 0.6875rem;
  }

  /* Smaller badge */
  .fm-tile-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.6rem;
    top: 4px;
    right: 4px;
  }

  /* Wide tile (7th button) - more compact */
  .fm-tile-wide {
    min-height: 44px;
    padding: 8px 12px;
    gap: 10px;
  }

  .fm-tile-wide .fm-tile-icon {
    margin-bottom: 0;
  }

  /* Reduce hero profile section spacing */
  .fm-hero-profile {
    padding: 0 14px 8px;
    margin-top: -6px;
  }

  /* Smaller headshot */
  .fm-headshot,
  .fm-headshot-placeholder {
    width: 56px;
    height: 56px;
  }

  /* Smaller headshot badge */
  .fm-headshot-badge {
    width: 18px;
    height: 18px;
  }

  .fm-headshot-badge svg {
    width: 10px;
    height: 10px;
  }

  /* Smaller name */
  .fm-hero-name {
    font-size: 1.125rem;
    margin: 6px 0 2px;
  }

  /* Smaller dates */
  .fm-hero-dates {
    font-size: 0.75rem;
  }

  /* Smaller contributions badge */
  .fm-hero-contributions {
    margin-top: 4px;
    padding: 3px 10px;
    font-size: 0.6875rem;
  }

  /* Compact header */
  .fm-hero-header {
    padding: 6px 10px;
  }

  /* Compact header buttons */
  .fm-close-btn,
  .fm-feedback-btn {
    width: 28px;
    height: 28px;
  }

  .fm-close-btn svg,
  .fm-feedback-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* =============================================================================
   AI DIALOGUE MODAL (v5.1.0 - Tell Your Story Feature)
   ============================================================================= */

.ai-dialogue-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: var(--space-md);
}

.ai-dialogue-modal.active {
  display: flex;
}

.ai-dialogue-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.ai-dialogue-container {
  position: relative;
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

.ai-dialogue-header {
  padding: var(--space-lg);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark, #5a67d8));
  color: white;
  position: relative;
}

.ai-dialogue-header h3 {
  margin: 0 0 var(--space-xs) 0;
  font-size: var(--font-xl);
  font-weight: 700;
}

.ai-dialogue-subtitle {
  margin: 0;
  opacity: 0.9;
  font-size: var(--font-sm);
}

.ai-dialogue-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: white;
  font-size: var(--font-xl);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.ai-dialogue-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ai-dialogue-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  min-height: 200px;
  max-height: 400px;
  background: var(--color-bg-secondary);
}

.ai-dialogue-welcome {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ai-dialogue-welcome .ai-avatar {
  font-size: 2.5rem;
  flex-shrink: 0;
}

.ai-welcome-text {
  flex: 1;
}

.ai-welcome-text p {
  margin: 0 0 var(--space-sm) 0;
  color: var(--color-text);
  line-height: 1.5;
}

.ai-welcome-text .ai-prompts {
  font-weight: 600;
  margin-top: var(--space-md);
  color: var(--color-primary);
}

.ai-welcome-text ul {
  margin: var(--space-xs) 0 0 0;
  padding-left: var(--space-lg);
  color: var(--color-text-light);
}

.ai-welcome-text li {
  margin-bottom: var(--space-xs);
  font-style: italic;
}

.ai-dialogue-message {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  animation: messageSlideIn 0.3s ease-out;
}

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

.ai-dialogue-message.user {
  flex-direction: row-reverse;
}

.ai-dialogue-message .message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.ai-dialogue-message .message-content {
  max-width: 75%;
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  line-height: 1.5;
}

.ai-dialogue-message.user .message-content {
  background: var(--color-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-dialogue-message.assistant .message-content {
  background: white;
  color: var(--color-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.ai-dialogue-message.typing .message-content {
  padding: var(--space-sm) var(--space-md);
}

.ai-dialogue-input-area {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}

.ai-dialogue-input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--font-base);
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.2s ease;
}

.ai-dialogue-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.ai-dialogue-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.ai-dialogue-send {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.ai-dialogue-send:hover:not(:disabled) {
  background: var(--color-primary-dark, #5a67d8);
  transform: translateY(-1px);
}

.ai-dialogue-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-dialogue-footer {
  padding: var(--space-md) var(--space-lg);
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
}

.ai-dialogue-finish {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ai-dialogue-finish:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.ai-dialogue-finish:disabled {
  background: var(--color-text-light);
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .ai-dialogue-modal {
    padding: 0;
    align-items: flex-end;
  }

  .ai-dialogue-container {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 85vh;
  }

  .ai-dialogue-messages {
    max-height: 50vh;
  }

  .ai-dialogue-message .message-content {
    max-width: 85%;
  }
}

/* =============================================================================
   SEGMENTED VIDEO PLAYER (v5.1.0 - Chapter Markers & Transcript Sync)
   ============================================================================= */

.segmented-video-player-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10002;
  padding: var(--space-md);
}

.segmented-video-player-modal.active {
  display: flex;
}

.segmented-video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
}

/* v5.2.6: Wrapper and close bar for Safari compatibility */
.segmented-video-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  width: 95vw;
  max-height: 95vh;
}

.segmented-video-close-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.segmented-video-close-bar .video-title {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  font-weight: 500;
}

.segmented-video-close-btn {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.segmented-video-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.segmented-video-close-btn:active {
  transform: scale(0.97);
  background: rgba(255, 255, 255, 0.3);
}

.segmented-video-container {
  position: relative;
  background: #1a1a1a;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  width: 100%;
  max-height: calc(95vh - 60px);
  display: flex;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.segmented-video-container.has-segments {
  flex-direction: row;
}

/* v5.2.6: Hide old close button */
.segmented-video-close {
  display: none;
}

/* Keep old styles for reference but hidden */
.segmented-video-close-old {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  color: white;
  font-size: var(--font-xl);
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  /* Safari touch target fix */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.segmented-video-close:hover {
  background: rgba(0, 0, 0, 0.9);
}

.segmented-video-close:active {
  transform: scale(0.95);
}

.segmented-video-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: black;
  min-width: 0;
}

.segmented-video-main video {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

/* Sidebar with segments */
.segmented-video-sidebar {
  width: 320px;
  background: #1a1a1a;
  border-left: 1px solid #333;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.segment-list-header {
  padding: var(--space-md);
  border-bottom: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.segment-list-header h4 {
  margin: 0;
  color: white;
  font-size: var(--font-base);
}

.segment-count {
  font-size: var(--font-xs);
  color: #888;
}

.segment-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
}

.segment-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: var(--space-xs);
}

.segment-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.segment-item.active {
  background: rgba(102, 126, 234, 0.3);
  border-left: 3px solid var(--color-primary);
}

.segment-time {
  font-size: var(--font-sm);
  color: var(--color-primary);
  font-weight: 600;
  min-width: 45px;
  font-family: monospace;
}

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

.segment-title {
  font-size: var(--font-sm);
  color: white;
  font-weight: 500;
  margin-bottom: 2px;
}

.segment-preview {
  font-size: var(--font-xs);
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segment-duration {
  font-size: var(--font-xs);
  color: #666;
  min-width: 30px;
  text-align: right;
}

.current-transcript {
  padding: var(--space-md);
  border-top: 1px solid #333;
  background: #222;
}

.transcript-label {
  font-size: var(--font-xs);
  color: #888;
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.transcript-text {
  font-size: var(--font-sm);
  color: white;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}

/* Mobile: Stack layout */
@media (max-width: 900px) {
  .segmented-video-container.has-segments {
    flex-direction: column;
  }

  .segmented-video-sidebar {
    width: 100%;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid #333;
  }

  .segmented-video-main video {
    max-height: 50vh;
  }
}

@media (max-width: 640px) {
  .segmented-video-player-modal {
    padding: 0;
  }

  .segmented-video-container {
    border-radius: 0;
    max-height: 100vh;
    height: 100vh;
  }

  .segmented-video-sidebar {
    max-height: 35vh;
  }

  .segment-list-header {
    padding: var(--space-sm) var(--space-md);
  }

  .segment-item {
    padding: var(--space-xs) var(--space-sm);
  }
}

/* v5.2.0: iOS Safari touch handling fixes */
.fm-tile {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(102, 126, 234, 0.3);
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 10;
}

.fm-tile-grid {
  touch-action: manipulation;
  pointer-events: auto;
  position: relative;
  z-index: 5;
}

/* v5.2.0: FIX - When panel is active, modal must be fullscreen to contain it */
/* The modal is normally a centered popup, but panels need fullscreen */
.fm-modal:has(.fm-panel.active) {
  /* Override the centered popup positioning */
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  transform: none !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
}

/* Fallback for browsers that don't support :has() */
@supports not selector(:has(*)) {
  .fm-modal {
    overflow: visible !important;
  }
  .fm-panel.active {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
  }
}
