/* ============================================================================
   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-primary: #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);
}

/* v5.2.16: Enhanced Media Browser Styles */
.media-card-thumbnail {
  width: 100%;
  aspect-ratio: 4/3;
  background: #f3f4f6;
  position: relative;
  overflow: hidden;
}

.media-card-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.media-card:hover .media-card-thumbnail img {
  transform: scale(1.05);
}

.media-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
}

.media-card-placeholder span {
  font-size: 48px;
  opacity: 0.7;
}

.media-card-type {
  background: rgba(102, 126, 234, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.media-card-date {
  color: #9ca3af;
}

/* Media Loading */
.media-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: #6b7280;
}

.media-loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e5e7eb;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Media Empty State */
.media-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #6b7280;
}

.media-empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.media-empty-state h3 {
  margin: 0 0 8px;
  color: #374151;
}

.media-empty-state p {
  margin: 0;
  font-size: 14px;
}

/* Media Detail Modal */
.media-detail-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  display: none;
}

.media-detail-modal.active {
  display: block;
}

.media-detail-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

.media-detail-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 16px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.media-detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.media-detail-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.media-detail-view {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  max-height: 60vh;
}

.media-detail-view img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.media-detail-view video {
  max-width: 100%;
  max-height: 100%;
}

.media-detail-placeholder {
  padding: 60px;
  text-align: center;
  color: white;
}

.media-detail-icon {
  font-size: 64px;
  display: block;
  margin-bottom: 16px;
}

.media-detail-info {
  padding: 24px;
  background: white;
}

.media-detail-info h2 {
  margin: 0 0 8px;
  font-size: 18px;
  color: #111827;
}

.media-detail-date {
  color: #6b7280;
  margin: 0 0 12px;
}

.media-detail-desc {
  color: #374151;
  margin: 0 0 16px;
  line-height: 1.6;
}

.media-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: #9ca3af;
}

.media-detail-meta span {
  background: #f3f4f6;
  padding: 4px 10px;
  border-radius: 6px;
}

/* Mobile Responsive Media */
@media (max-width: 768px) {
  .media-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .media-card-placeholder span {
    font-size: 32px;
  }

  .media-card-info {
    padding: 8px 10px;
  }

  .media-card-title {
    font-size: 12px;
  }

  .media-card-meta {
    font-size: 10px;
  }

  .media-detail-content {
    max-width: 95vw;
    max-height: 95vh;
    border-radius: 12px;
  }

  .media-detail-view {
    max-height: 50vh;
  }

  .media-detail-info {
    padding: 16px;
  }

  .media-detail-info h2 {
    font-size: 16px;
  }

  .media-detail-close {
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 480px) {
  .media-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .media-card {
    border-radius: 8px;
  }

  .media-card-thumbnail {
    aspect-ratio: 1;
  }
}

/* ============================================================================
   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;
}

/* Biography AI Modal must appear above Family Member Modal (v6.4.2) */
#biographyAIModal {
  z-index: 10001;
}

#biographyAIModal .modal-content {
  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;
}

/* v6.5.7: iPhone Navigation - Home button in modal headers */
.mobile-modal-home {
  position: absolute;
  right: 55px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 10;
}

.mobile-modal-home:hover {
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
}

.mobile-modal-home:active {
  transform: translateY(-50%) scale(0.95);
}

/* Hide home button on desktop - only for mobile */
@media (min-width: 1024px) {
  .mobile-modal-home {
    display: none;
  }
}

/* Adjust close button position when home button is present */
.mobile-modal-header.with-home .mobile-modal-close {
  right: var(--space-md);
}

/* 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;
}

/* v5.2.16: Mobile touch - always show action buttons (no hover on touch) */
@media (max-width: 768px) {
  .training-photo-actions {
    opacity: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    padding: 4px;
  }

  .training-photo-actions button {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
}

/* 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 */
/* v7.3.0: Fixed to respect header height - backdrops must never cover header */
.fm-modal-backdrop {
  position: fixed;
  top: var(--nav-height);
  left: var(--side-nav-width);
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: none;
  pointer-events: auto;
}

/* Mobile: backdrop respects half-height header */
@media (max-width: 767px) {
  .fm-modal-backdrop {
    top: calc(var(--nav-height) / 2);
    left: 0;
  }
}

.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 */
/* v6.5.3: Narrower on desktop (25% less) so Dashboard visible behind */
.fm-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;
  max-width: 315px; /* v6.5.3: Was 420px, now 25% narrower */
  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.2.12: iPhone full-height modal - fills from header to bottom */
@media (max-width: 767px) {
  .fm-modal {
    top: var(--nav-height, 60px);
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    max-height: none;
    height: calc(100vh - var(--nav-height, 60px));
    border-radius: 16px 16px 0 0;
  }
}

/* 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);
}

/* v7.1.0: Home button for iPhone navigation */
.fm-home-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 18px;
  margin-right: 8px;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.fm-home-btn:active {
  transform: scale(0.95);
  box-shadow: 0 1px 4px rgba(59, 130, 246, 0.4);
}

/* Hide home button on desktop */
@media (min-width: 1024px) {
  .fm-home-btn {
    display: none;
  }
}

/* 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.2.11: Increased gap now that we have 6 tiles in 2x3 grid */
  gap: 12px;
  padding: 0 16px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.fm-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* v5.2.11: Slightly taller tiles now that we have 6 instead of 7 */
  padding: 16px 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: 85px;
}

.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; }
.fm-tile-gray .fm-tile-icon { background: linear-gradient(135deg, #f3f4f6, #e5e7eb); color: #6b7280; }

/* Hover effects for desktop */
@media (hover: hover) {
  .fm-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  }
}

/* ======================= v6.1.0: TRAINING STATUS INDICATORS ======================= */

.fm-training-status {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  margin-top: 8px;
}

.training-status-control {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  border: none;
  font-size: 13px;
  font-weight: 500;
}

.training-status-control.incomplete {
  background: rgba(239, 68, 68, 0.12);
  border: 2px solid rgba(239, 68, 68, 0.4);
  color: #dc2626;
}

.training-status-control.complete {
  background: rgba(34, 197, 94, 0.12);
  border: 2px solid rgba(34, 197, 94, 0.4);
  color: #16a34a;
}

.training-status-control:active {
  transform: scale(0.98);
}

.training-status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.training-status-indicator.red {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.training-status-indicator.green {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.training-status-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.training-status-text {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ======================= v5.2.17: LEADERBOARD STRIP ======================= */

.fm-leaderboard-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 8px 16px 0;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.15) 100%);
  border-radius: 12px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.fm-leaderboard-strip-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 0;
}

.fm-leaderboard-strip-content::-webkit-scrollbar {
  display: none;
}

.fm-strip-leader {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 4px 8px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.fm-strip-leader.fm-strip-you {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.fm-strip-leader.fm-strip-you .fm-strip-points {
  color: rgba(255, 255, 255, 0.9);
}

.fm-strip-rank {
  font-size: 12px;
}

.fm-strip-name {
  font-size: 12px;
  font-weight: 600;
  color: #1f2937;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fm-strip-you .fm-strip-name {
  color: white;
}

.fm-strip-points {
  font-size: 11px;
  color: #6b7280;
  font-weight: 500;
}

.fm-strip-divider {
  color: #d1d5db;
  font-size: 14px;
  flex-shrink: 0;
}

.fm-strip-expand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(16, 185, 129, 0.2);
  border-radius: 50%;
  color: #059669;
  cursor: pointer;
  flex-shrink: 0;
}

.fm-strip-expand:active {
  background: rgba(16, 185, 129, 0.3);
}

.fm-strip-loading {
  font-size: 12px;
  color: #6b7280;
  padding: 4px 0;
}

.fm-strip-empty {
  font-size: 12px;
  color: #059669;
  font-weight: 500;
}

.fm-strip-error {
  font-size: 12px;
  color: #6b7280;
}

/* ======================= 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;
}

/* v7.1.0: Home button for panel headers (iPhone navigation) */
.fm-panel-home {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.15) 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
  margin-left: auto;
  margin-right: 8px;
}

.fm-panel-home:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.35);
}

/* Hide home button on desktop */
@media (min-width: 1024px) {
  .fm-panel-home {
    display: none;
  }
}

.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: 12px; /* v6.4.1: Reduced from 24px */
}

.fm-form-section {
  background: white;
  border-radius: 12px; /* v6.4.1: Reduced from 16px */
  padding: 12px 14px; /* v6.4.1: Reduced from 20px */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* v6.4.1: Further vertical compression for compact sections */
.fm-form-section-compact {
  padding: 10px 14px;
}

/* v6.5.3: Hide section titles (Name, Contact, Dates) and their lines */
.fm-form-section-compact .fm-form-section-title {
  display: none;
}

/* v6.5.3: Hide Gender field entirely */
.fm-form-field:has(#editGender) {
  display: none;
}

/* v6.5.3: Mobile - Extra vertical compression so Biography visible without scroll */
@media (max-width: 767px) {
  .fm-form-section-compact {
    padding: 6px 12px;
    margin-bottom: 4px;
  }

  .fm-form-section-compact .fm-form-grid {
    margin-bottom: 4px;
  }

  .fm-form-section-compact .fm-field-input {
    padding: 6px 8px;
    font-size: 0.875rem;
  }

  .fm-form-section-compact .fm-field-label {
    font-size: 0.7rem;
    margin-bottom: 2px;
  }

  /* Compress Biography section on mobile */
  .fm-form-section-biography {
    padding: 8px 12px;
  }

  .fm-form-section-biography .fm-form-section-header {
    margin-bottom: 6px;
    padding-bottom: 4px;
  }

  .fm-field-textarea {
    min-height: 80px;
  }
}

.fm-form-section-compact .fm-form-grid {
  margin-bottom: 6px;
}

.fm-form-section-compact .fm-field-input {
  padding: 8px 10px;
  font-size: 0.9375rem;
}

/* v6.4.0: Biography section with header controls */
.fm-form-section-biography {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.fm-form-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f3f4f6;
}

.fm-form-section-header .fm-form-section-title {
  margin: 0;
  padding: 0;
  border: none;
}

.fm-biography-controls {
  display: flex;
  gap: 8px;
}

.fm-bio-mic-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #e5e7eb;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #6b7280;
}

.fm-bio-mic-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.fm-bio-mic-btn.recording {
  border-color: #ef4444;
  background: #fef2f2;
  color: #ef4444;
  animation: pulse-mic 1s infinite;
}

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

.fm-bio-ai-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 2px solid #667eea;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* v6.4.1: Scrollable textarea for biography - indefinite length */
.fm-field-textarea-expandable {
  min-height: 100px;
  max-height: 200px; /* Fixed max-height for scrolling */
  overflow-y: auto;
  resize: none; /* Prevent manual resize, content scrolls instead */
  flex: 1;
  line-height: 1.5;
}

.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.75rem; /* v6.4.1: Reduced from 0.8125rem */
  font-weight: 500;
  color: #374151;
}

.fm-field-input,
.fm-field-textarea {
  width: 100%;
  padding: 10px 12px; /* v6.4.1: Reduced from 12px 14px */
  font-size: 0.9375rem; /* v6.4.1: Reduced from 1rem */
  border: 2px solid #e5e7eb;
  border-radius: 8px; /* v6.4.1: Reduced from 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 TABS v5.3.2 ======================= */

.fm-training-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.fm-training-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s ease;
}

.fm-training-tab:hover {
  border-color: #d1d5db;
  color: #374151;
}

.fm-training-tab.active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: transparent;
  color: white;
}

.fm-training-tab.active svg {
  stroke: white;
}

.fm-training-tab[data-tab="voice"].active {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.fm-training-tab-content {
  display: none;
}

.fm-training-tab-content.active {
  display: block;
}

/* ======================= VOICE PROMPT v5.3.2 ======================= */

.fm-voice-prompt-section {
  margin-bottom: 24px;
  width: 100%;
}

.fm-voice-prompt-card {
  position: relative;
  background: linear-gradient(135deg, #fefce8 0%, #fef3c7 100%);
  border: 2px solid #fcd34d;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 8px;
}

.fm-voice-prompt-text {
  font-size: 1.125rem;
  line-height: 1.6;
  color: #78350f;
  margin: 0;
  font-style: italic;
}

.fm-voice-prompt-text .fm-prompt-name {
  font-weight: 700;
  color: #92400e;
  font-style: normal;
}

.fm-voice-prompt-shuffle {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 1px solid #fcd34d;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
}

.fm-voice-prompt-shuffle:hover {
  background: #fef3c7;
  transform: rotate(180deg);
}

.fm-voice-prompt-shuffle svg {
  stroke: #d97706;
}

.fm-voice-prompt-hint {
  font-size: 0.8125rem;
  color: #6b7280;
  text-align: center;
  margin: 0;
}

/* Voice waveform enhancements */
.fm-waveform-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.fm-recording-quality {
  font-size: 0.75rem;
  color: #6b7280;
  padding: 4px 8px;
  background: #f3f4f6;
  border-radius: 6px;
}

.fm-recording-quality.good {
  background: #d1fae5;
  color: #065f46;
}

.fm-recording-quality.fair {
  background: #fef3c7;
  color: #92400e;
}

.fm-recording-quality.poor {
  background: #fee2e2;
  color: #991b1b;
}

/* ======================= 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%);
}

/* v6.3.0: Gray header for My Activity panel */
.fm-panel-header-gray {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 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 - v5.2.11: Mobile-first SINGLE column grid */
.fm-docs-list {
  display: grid;
  grid-template-columns: 1fr;  /* Single column on mobile for readability */
  gap: 12px;
}

/* v5.2.11: Card layout - horizontal on mobile (thumbnail left, info right) */
.fm-doc-item {
  display: flex;
  flex-direction: row;  /* Horizontal layout on mobile */
  gap: 12px;
  padding: 12px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  border-left: 3px solid;  /* Left border for status color */
  border-top: none;
}

/* v5.2.11: Smaller square thumbnails on mobile (single column layout) */
.fm-doc-thumbnail {
  width: 70px;
  height: 70px;
  min-width: 70px;
  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;
  }
}

/* v5.2.11: Tablet (768px+): 2 equal-width columns, vertical cards */
@media (min-width: 768px) {
  .fm-docs-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    width: 100%;
  }

  .fm-doc-item {
    flex-direction: column;  /* Vertical layout on tablet+ */
    padding: 14px;
    border-top: 4px solid;
    border-left: none;
    min-width: 0;
    width: 100%;
  }

  .fm-doc-thumbnail {
    width: 100%;
    height: 120px;
    min-width: unset;
    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;
  }
}

/* v5.2.11: Desktop (1024px+): 3 columns, larger cards */
@media (min-width: 1024px) {
  .fm-docs-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
  }

  .fm-doc-item {
    padding: 18px;
  }

  .fm-doc-thumbnail {
    height: 160px;
    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);
}

/* v6.5.8: Leaderboard Hero Presentation - "Wow Moment" */

/* Hero Header Animation */
#view-leaderboard .view-header {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
  color: white;
  padding: 32px 24px;
  border-radius: 0 0 24px 24px;
  margin: -16px -16px 24px -16px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(245, 158, 11, 0.4);
}

#view-leaderboard .view-header h2 {
  font-size: 2rem;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Animated Trophy */
#view-leaderboard .view-header h2::before {
  content: '🏆';
  display: inline-block;
  font-size: 2.5rem;
  margin-right: 12px;
  animation: trophy-bounce 1.5s ease-in-out infinite;
}

@keyframes trophy-bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-8px) rotate(-5deg); }
  50% { transform: translateY(0) rotate(0deg); }
  75% { transform: translateY(-4px) rotate(5deg); }
}

/* Period Toggle in Hero */
#view-leaderboard .leaderboard-period-toggle {
  margin-top: 20px;
  justify-content: center;
}

#view-leaderboard .period-btn {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  color: white;
  transition: all 0.3s ease;
}

#view-leaderboard .period-btn.active {
  background: white;
  color: #b45309;
  border-color: white;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Animated Leader Cards */
.leader-card {
  animation: slide-in-right 0.5s ease-out forwards;
  opacity: 0;
  transform: translateX(50px);
}

.leader-card:nth-child(1) { animation-delay: 0.1s; }
.leader-card:nth-child(2) { animation-delay: 0.2s; }
.leader-card:nth-child(3) { animation-delay: 0.3s; }
.leader-card:nth-child(4) { animation-delay: 0.4s; }
.leader-card:nth-child(5) { animation-delay: 0.5s; }
.leader-card:nth-child(6) { animation-delay: 0.6s; }
.leader-card:nth-child(7) { animation-delay: 0.7s; }
.leader-card:nth-child(8) { animation-delay: 0.8s; }
.leader-card:nth-child(9) { animation-delay: 0.9s; }
.leader-card:nth-child(10) { animation-delay: 1.0s; }

@keyframes slide-in-right {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Top 3 Podium Enhancement */
.leader-card.rank-1 {
  position: relative;
  transform: scale(1.02);
  z-index: 3;
}

.leader-card.rank-1::before {
  content: '🌟 TOP CONTRIBUTOR 🌟';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.leader-card.rank-1 .leader-rank {
  font-size: 2.5rem;
  animation: crown-shimmer 2s ease-in-out infinite;
}

@keyframes crown-shimmer {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3) drop-shadow(0 0 8px gold); }
}

/* Glowing rank badges for top 3 */
.leader-card.rank-2 .leader-rank,
.leader-card.rank-3 .leader-rank {
  font-size: 2rem;
}

/* Family Goal Card Enhancement */
.family-goal-card {
  animation: fade-in-up 0.6s ease-out 0.2s forwards;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes fade-in-up {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Goal Progress Bar Animation */
.goal-progress-fill {
  transition: width 1.5s ease-out;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  position: relative;
  overflow: hidden;
}

.goal-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  100% { left: 100%; }
}

/* Your Stats Card Animation */
.your-stats-card {
  animation: pop-in 0.4s ease-out 1.2s forwards;
  opacity: 0;
  transform: scale(0.9);
}

@keyframes pop-in {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 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;
}

/* v7.1.0: Home button for AI modal (iPhone navigation) */
.ai-modal-home {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 10;
}

.ai-modal-home:hover {
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
}

.ai-modal-home:active {
  transform: translateY(-50%) scale(0.95);
}

/* Hide home button on desktop */
@media (min-width: 1024px) {
  .ai-modal-home {
    display: none;
  }
}

/* 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
   v7.3.0: Fixed to respect header height - modals must never cover header
   ============================================================================ */

.leaderboard-hero-overlay {
  position: fixed;
  top: var(--nav-height);
  left: var(--side-nav-width);
  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;
}

/* Mobile: hero overlay takes full width but respects half-height header */
@media (max-width: 767px) {
  .leaderboard-hero-overlay {
    top: calc(var(--nav-height) / 2);
    left: 0;
  }
}

.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;
  }
}

/* ============================================================================
   Leaderboard Hero Side-by-Side (v7.2.0)
   Shows alongside Family Member Modal on first open (desktop only)
   v7.2.0: Fixed to respect sidebar, position within app content area
   ============================================================================ */

.leaderboard-hero-side-by-side {
  position: fixed;
  top: 0;
  left: 0;
  width: 38%;
  height: 100%;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  z-index: 10000; /* Below modal but above backdrop */
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateX(-100%);
}

.leaderboard-hero-side-by-side.hero-visible {
  opacity: 1;
  transform: translateX(0);
}

.leaderboard-hero-side-by-side.hero-hiding {
  opacity: 0;
  transform: translateX(-100%);
  pointer-events: none;
}

.hero-side-panel {
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: heroSlideIn 0.4s ease-out;
}

@keyframes heroSlideIn {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* When side-by-side hero is visible, adjust modal position */
.leaderboard-hero-side-by-side.hero-visible ~ .fm-modal-backdrop.active,
.leaderboard-hero-side-by-side.hero-visible ~ .fm-modal.active {
  left: 38%;
  width: 62%;
}

/* Ensure modal backdrop doesn't cover the side panel */
body:has(.leaderboard-hero-side-by-side.hero-visible) .fm-modal-backdrop.active {
  left: 38%;
  width: 62%;
}

body:has(.leaderboard-hero-side-by-side.hero-visible) .fm-modal.active {
  left: 38%;
  width: 62%;
}

/* v7.2.0: Hide dashboard/main content when hero is visible (navigation is in sidebar) */
body:has(.leaderboard-hero-side-by-side.hero-visible) .main-content {
  visibility: hidden;
}

/* Tablet: slightly wider side panel */
@media (min-width: 768px) and (max-width: 1023px) {
  .leaderboard-hero-side-by-side {
    width: 45%;
  }

  body:has(.leaderboard-hero-side-by-side.hero-visible) .fm-modal-backdrop.active,
  body:has(.leaderboard-hero-side-by-side.hero-visible) .fm-modal.active {
    left: 45%;
    width: 55%;
  }
}

/* Mobile: Hide side-by-side (mobile uses overlay instead) */
@media (max-width: 767px) {
  .leaderboard-hero-side-by-side {
    display: none !important;
  }
}

/* ============================================================================
   v7.2.0: Desktop Hero Layout - Respect Sidebar
   On desktop (≥1024px), hero and modal render within the app content area
   (to the right of the sidebar), not over the entire viewport.
   ============================================================================ */
@media (min-width: 1024px) {
  /* Leaderboard panel: starts at sidebar edge, takes left half of content area */
  .leaderboard-hero-side-by-side {
    left: var(--side-nav-width);
    top: var(--nav-height);
    height: calc(100% - var(--nav-height));
    /* Width = half of content area = (100% - sidebar) / 2 */
    width: calc((100% - var(--side-nav-width)) / 2);
  }

  /* FM Modal when hero is visible: center in right half of content area */
  body:has(.leaderboard-hero-side-by-side.hero-visible) .fm-modal-backdrop.active {
    /* Left edge = sidebar + left half = sidebar + (100% - sidebar) / 2 */
    left: calc(var(--side-nav-width) + (100% - var(--side-nav-width)) / 2);
    width: calc((100% - var(--side-nav-width)) / 2);
  }

  body:has(.leaderboard-hero-side-by-side.hero-visible) .fm-modal.active {
    /* v7.3.5: Center the modal within the right half of the content area */
    /* Right half starts at sidebar + half content width */
    /* Modal should be centered within that half, so its center should be at:
       sidebar + half content + quarter content = sidebar + 3/4 content */
    /* That's: sidebar + 75% of (100% - sidebar) = sidebar + 75% - 0.75*sidebar = 0.25*sidebar + 75% */
    left: calc(var(--side-nav-width) * 0.25 + 75%);
    transform: translate(-50%, -50%);
    top: calc(var(--nav-height) + (100vh - var(--nav-height)) / 2);
    width: auto;
    max-width: 315px;
  }

  /* Sibling selectors for browsers that don't support :has() */
  .leaderboard-hero-side-by-side.hero-visible ~ .fm-modal-backdrop.active {
    left: calc(var(--side-nav-width) + (100% - var(--side-nav-width)) / 2);
    width: calc((100% - var(--side-nav-width)) / 2);
  }

  .leaderboard-hero-side-by-side.hero-visible ~ .fm-modal.active {
    /* v7.3.5: Center the modal within the right half */
    left: calc(var(--side-nav-width) * 0.25 + 75%);
    transform: translate(-50%, -50%);
    top: calc(var(--nav-height) + (100vh - var(--nav-height)) / 2);
    width: auto;
    max-width: 315px;
  }
}

/* ============================================================================
   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);
}

/* v6.5.3: Title section with Add Story button */
.stories-title-section {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.stories-title-section h2 {
  margin: 0;
  font-size: var(--font-2xl);
}

/* v6.5.3: Add Story button in header */
.add-story-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

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

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

.add-story-icon {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Mobile: Hide text, show only icon */
@media (max-width: 767px) {
  /* v6.5.2: Ensure title section keeps button visible on mobile portrait */
  .stories-title-section {
    width: 100%;
    justify-content: space-between;
  }

  .stories-title-section h2 {
    flex: 1;
    min-width: 0; /* Allow text to shrink if needed */
  }

  .add-story-btn {
    padding: 8px 12px;
    flex-shrink: 0; /* Don't allow button to shrink */
  }

  .add-story-text {
    display: none;
  }
}

.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);
}

/* v5.2.17: Person Filter Pill */
.stories-person-filter-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-radius: 20px;
  color: white;
  font-size: 14px;
  margin-bottom: 12px;
}

.person-filter-label {
  opacity: 0.9;
}

.person-filter-name {
  font-weight: 600;
}

.person-filter-clear {
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  font-size: 12px;
  margin-left: 4px;
}

.person-filter-clear:hover {
  background: rgba(255,255,255,0.4);
}

/* ============================================================================
   v6.5.1: STORY FILTER PANEL STYLES
   ============================================================================ */

.story-filter-panel {
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-md) var(--space-lg);
}

/* Focal Person Indicator (when entering from Family Member Modal) */
.focal-person-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-radius: var(--radius-md);
  color: white;
  font-size: var(--font-sm);
  margin-bottom: var(--space-md);
}

.focal-person-indicator strong {
  font-weight: 600;
}

.focal-person-clear {
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}

.focal-person-clear:hover {
  background: rgba(255,255,255,0.4);
}

/* Filter Panel Rows */
.filter-panel-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-panel-row-1 {
  margin-bottom: 8px;
}

/* Family Focus Button */
.family-focus-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

.family-focus-btn:hover {
  background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
}

.family-focus-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
}

.family-focus-icon {
  font-size: 16px;
}

.family-focus-label {
  white-space: nowrap;
}

.family-focus-badge {
  background: rgba(255,255,255,0.2);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
}

/* Era and Type Dropdowns */
.filter-select {
  padding: 10px 12px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--font-sm);
  min-height: 44px;
  min-width: 70px;
  cursor: pointer;
  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='%239ca3af' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.filter-era {
  min-width: 70px;
}

.filter-type {
  min-width: 80px;
}

/* Search Input */
.filter-search-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.filter-search-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  color: var(--color-text-light);
  pointer-events: none;
}

.filter-search-input {
  width: 100%;
  padding: 10px 36px 10px 36px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--font-sm);
  min-height: 44px;
}

.filter-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.filter-search-input::placeholder {
  color: var(--color-text-light);
}

.filter-search-clear {
  position: absolute;
  right: 8px;
  background: var(--color-bg-secondary);
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
  cursor: pointer;
  font-size: 12px;
}

.filter-search-clear:hover {
  background: var(--color-border);
  color: var(--color-text);
}

/* ============================================================================
   v6.5.1: FAMILY FOCUS MODAL STYLES
   ============================================================================ */

.family-focus-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.family-focus-modal {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  width: 95%;
  max-width: 500px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.3s ease-out;
}

.family-focus-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.family-focus-modal-header h3 {
  margin: 0;
  font-size: var(--font-lg);
  display: flex;
  align-items: center;
  gap: 8px;
}

.family-focus-close {
  background: none;
  border: none;
  color: var(--color-text-light);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.family-focus-close:hover {
  color: var(--color-text);
}

.family-focus-done {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
}

.family-focus-done:hover {
  opacity: 0.9;
}

.family-focus-search {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.family-focus-search input {
  width: 100%;
  padding: 12px 16px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--font-md);
}

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

.family-focus-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm) 0;
}

.family-focus-item {
  display: flex;
  align-items: center;
  padding: 12px var(--space-lg);
  cursor: pointer;
  transition: background 0.15s;
}

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

.family-focus-checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.15s;
  flex-shrink: 0;
}

.family-focus-item.selected .family-focus-checkbox {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
  color: white;
}

.family-focus-name {
  flex: 1;
  font-size: var(--font-md);
}

.family-focus-generation {
  font-size: var(--font-xs);
  color: var(--color-text-light);
  background: var(--color-bg-secondary);
  padding: 2px 8px;
  border-radius: 10px;
}

.family-focus-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.family-focus-clear-all {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-light);
  padding: 8px 16px;
  cursor: pointer;
}

.family-focus-clear-all:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.family-focus-selected-count {
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

/* Story Profile button in Family Focus modal */
.family-focus-story-profile-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.family-focus-story-profile-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.family-focus-story-profile-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================================
   v6.8.0: STORY PROFILE MODAL
   Drag-to-reorder story ordering for focus groups
   ============================================================================ */

.story-profile-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: 10002;
  animation: fadeIn 0.2s ease-out;
}

.story-profile-modal {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease-out;
}

.story-profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.story-profile-header h3 {
  margin: 0;
  font-size: var(--font-lg);
  color: var(--color-text);
  flex: 1;
  text-align: center;
}

.story-profile-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--color-text-light);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.story-profile-close:hover {
  color: var(--color-text);
}

.story-profile-save {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  padding: 8px 16px;
  font-weight: 500;
  cursor: pointer;
}

.story-profile-save:hover {
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.story-profile-hint {
  padding: var(--space-sm) var(--space-lg);
  margin: 0;
  font-size: var(--font-sm);
  color: var(--color-text-light);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.story-profile-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
}

.story-profile-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: grab;
  transition: all 0.2s ease;
}

.story-profile-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.story-profile-item.dragging {
  opacity: 0.5;
  border-style: dashed;
  cursor: grabbing;
}

.story-profile-drag-handle {
  color: var(--color-text-light);
  font-size: 16px;
  cursor: grab;
}

.story-profile-rank {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--font-sm);
  flex-shrink: 0;
}

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

.story-profile-title {
  display: block;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-profile-arc {
  display: block;
  font-size: var(--font-xs);
  color: var(--color-text-light);
  margin-top: 2px;
}

.story-profile-empty {
  text-align: center;
  color: var(--color-text-light);
  padding: var(--space-xl);
}

.story-profile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.story-profile-clear {
  background: none;
  border: 1px solid var(--color-error);
  border-radius: var(--radius-md);
  color: var(--color-error);
  padding: 8px 16px;
  cursor: pointer;
}

.story-profile-clear:hover {
  background: var(--color-error);
  color: white;
}

.story-profile-cancel {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-light);
  padding: 8px 16px;
  cursor: pointer;
  margin-left: auto;
}

.story-profile-cancel:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

/* Mobile optimizations for Story Profile */
@media (max-width: 768px) {
  .story-profile-modal {
    width: 95%;
    max-height: 85vh;
  }

  .story-profile-item {
    padding: var(--space-sm) var(--space-md);
  }

  .story-profile-drag-handle {
    font-size: 20px;
    padding: 4px;
  }
}

/* ============================================================================
   v6.5.1: RESPONSIVE STYLES FOR FILTER PANEL
   ============================================================================ */

/* Desktop: Single row layout */
@media (min-width: 769px) {
  .story-filter-panel {
    display: flex;
    flex-direction: column;
  }

  .filter-panel-row-1 {
    margin-bottom: 0;
  }

  .story-filter-panel .filter-panel-row {
    display: contents;
  }

  .story-filter-panel {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }

  .focal-person-indicator {
    margin-bottom: 0;
    margin-right: auto;
  }

  .filter-search-wrapper {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
  }

  /* Multi-column layout for modal */
  .family-focus-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .family-focus-modal {
    max-width: 600px;
  }
}

/* iPhone: Two row layout */
@media (max-width: 768px) {
  .story-filter-panel {
    padding: var(--space-sm) var(--space-md);
  }

  .filter-panel-row-1 {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .filter-panel-row-2 {
    margin-top: 8px;
  }

  .family-focus-btn {
    padding: 8px 12px;
    min-width: auto;
  }

  .filter-select {
    padding: 8px 10px;
    min-width: 60px;
    font-size: var(--font-xs);
  }

  .filter-era {
    min-width: 55px;
  }

  .filter-type {
    min-width: 65px;
  }

  /* Full-screen modal on iPhone */
  .family-focus-modal-overlay {
    align-items: flex-end;
  }

  .family-focus-modal {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .family-focus-item {
    padding: 14px var(--space-md);
    min-height: 48px;
  }
}

/* v5.2.17: Never-Empty Stories View */
.stories-never-empty {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.stories-create-cta {
  background: linear-gradient(135deg, #1e3a5f 0%, #0d1b2a 100%);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  color: white;
}

.stories-create-cta-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
}

.stories-create-cta h3 {
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-xl);
}

.stories-create-cta p {
  margin: 0 0 var(--space-lg) 0;
  opacity: 0.8;
}

.stories-create-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: var(--font-md);
}

.stories-section {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.stories-section-header {
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  border-bottom: 1px solid var(--color-border);
}

.stories-section-header h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-lg);
}

.stories-section-header .section-icon {
  font-size: var(--font-xl);
}

.stories-section-subtitle {
  margin: 4px 0 0 0;
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.stories-section-cards {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.stories-welcome {
  text-align: center;
  padding: var(--space-2xl);
  background: linear-gradient(135deg, #1e3a5f 0%, #0d1b2a 100%);
  border-radius: var(--radius-lg);
  color: white;
}

.stories-welcome-icon {
  font-size: 64px;
  margin-bottom: var(--space-lg);
}

.stories-welcome h2 {
  margin: 0 0 var(--space-md) 0;
}

.stories-welcome p {
  opacity: 0.8;
  margin: 0 0 var(--space-xl) 0;
}

/* 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 History View (v5.3.3) */
.stories-history {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.stories-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
}

.stories-history-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.stories-history-title h3 {
  margin: 0;
  font-size: var(--font-lg);
  color: var(--color-text);
}

.stories-history-count {
  padding: 2px 8px;
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 600;
}

.stories-history-filters {
  display: flex;
  gap: var(--space-xs);
}

.stories-history-filter-btn {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-light);
  cursor: pointer;
  font-size: var(--font-sm);
  transition: all 0.2s ease;
}

.stories-history-filter-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.stories-history-filter-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

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

.story-history-card {
  display: flex;
  align-items: flex-start;
  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-history-card:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-primary);
  transform: translateX(4px);
}

.story-history-card.is-live {
  border-left: 4px solid #ef4444;
  background: linear-gradient(to right, rgba(239, 68, 68, 0.05), transparent);
}

.story-history-card.is-ended {
  border-left: 4px solid #22c55e;
}

.story-history-icon {
  font-size: var(--font-2xl);
  flex-shrink: 0;
  margin-top: 2px;
}

.story-history-content {
  flex: 1;
  min-width: 0;
}

.story-history-header-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.story-history-title {
  margin: 0;
  font-size: var(--font-lg);
  color: var(--color-text);
}

.story-status-badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 600;
}

.story-status-badge.live {
  background: #fef2f2;
  color: #dc2626;
  animation: pulse-live 2s infinite;
}

.story-status-badge.ended {
  background: #f0fdf4;
  color: #16a34a;
}

.story-status-badge.regular {
  background: var(--color-bg-secondary);
  color: var(--color-text-light);
}

@keyframes pulse-live {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.story-history-subtitle {
  margin: var(--space-xs) 0 0 0;
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.story-history-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-sm);
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.story-history-updated {
  color: var(--color-primary);
}

.story-history-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.story-history-stat {
  padding: 2px 8px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  font-size: var(--font-xs);
  color: var(--color-text-light);
}

.story-history-arrow {
  font-size: var(--font-xl);
  color: var(--color-text-light);
  flex-shrink: 0;
  align-self: center;
}

.stories-history-empty {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--color-text-light);
}

.stories-history-empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

/* Mobile responsive for Story History */
@media (max-width: 768px) {
  .stories-history-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stories-history-filters {
    width: 100%;
    overflow-x: auto;
    padding-bottom: var(--space-xs);
  }

  .story-history-card {
    padding: var(--space-md);
  }

  .story-history-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }
}

/* 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;
}

/* v6.1.0: Training Story Card Styling */
.story-card.training-story {
  position: relative;
  border: 2px dashed #f59e0b;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
}

.story-card.training-story:hover {
  background: linear-gradient(135deg, #fde68a, #fcd34d);
  border-color: #d97706;
}

.training-story-badge {
  position: absolute;
  top: -10px;
  left: 12px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.4);
  z-index: 1;
}

.story-card.training-story .story-card-title {
  color: #92400e;
}

.story-card.training-story .story-card-subtitle {
  color: #b45309;
}

.story-card.training-story .story-card-meta {
  color: #a16207;
}

.story-card.training-story .story-card-icon {
  background: rgba(217, 119, 6, 0.15);
}

/* 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);
}

/* v6.4.1: Story Media Gallery */
.story-media-header {
  font-size: var(--font-md);
  font-weight: 600;
  margin: 0 0 var(--space-sm) 0;
  color: var(--color-text);
}

.story-media-gallery {
  display: grid;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.story-video-gallery {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.story-photo-gallery {
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
}

.story-media-item {
  cursor: pointer;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.story-media-item:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.story-media-item.video-item {
  background: linear-gradient(135deg, #1e293b, #334155);
  padding: var(--space-sm);
}

.story-media-item .video-thumb {
  aspect-ratio: 16/9;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-media-item .play-overlay {
  font-size: 2rem;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.story-media-item .media-caption {
  font-size: 0.75rem;
  color: white;
  margin: var(--space-xs) 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-media-item.photo-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.story-media-item.more-photos {
  aspect-ratio: 1;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: var(--font-sm);
}

.story-photos-section {
  margin-bottom: var(--space-lg);
}

/* Story Photo Lightbox */
.story-photo-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
}

.story-photo-lightbox.active {
  display: flex;
}

.story-photo-lightbox .lightbox-content {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
}

.story-photo-lightbox .lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
}

.story-photo-lightbox img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

/* Story Gallery Modal */
.story-gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  display: none;
  overflow-y: auto;
}

.story-gallery-modal.active {
  display: block;
}

.story-gallery-modal .gallery-modal-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.story-gallery-modal .gallery-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  color: white;
}

.story-gallery-modal .gallery-modal-header h3 {
  margin: 0;
}

.story-gallery-modal .gallery-close-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
}

.story-gallery-modal .gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-md);
}

.story-gallery-modal .gallery-item {
  cursor: pointer;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.2s;
}

.story-gallery-modal .gallery-item:hover {
  transform: scale(1.05);
}

.story-gallery-modal .gallery-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

/* Gallery Load More Button (v6.4.2) */
.story-gallery-modal .gallery-load-more {
  display: flex;
  justify-content: center;
  padding: var(--space-lg) 0;
}

.story-gallery-modal .btn-load-more-gallery {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.story-gallery-modal .btn-load-more-gallery:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.story-gallery-modal .btn-load-more-gallery:active {
  transform: translateY(0);
}

/* 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;
  /* v5.2.14: Ensure clickable on Mac Safari */
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  /* v5.2.14: Explicit z-index and pointer-events for Safari */
  position: relative;
  z-index: 10002;
  pointer-events: auto !important;
}

.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);
  }
}

/* ============================================
   Story Sidebar Layout (v5.2.6)
   ============================================ */

/* Story Modal with Sidebar Layout */
.story-modal-layout {
  display: flex;
  min-height: calc(100vh - 140px); /* Account for header and tabs */
}

/* Left Sidebar - Contribution Tools */
.story-sidebar {
  width: 70px;
  min-width: 70px;
  background: linear-gradient(180deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.12) 100%);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md) var(--space-xs);
  gap: var(--space-sm);
  position: sticky;
  top: 140px; /* Below header and tabs */
  height: fit-content;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
}

.sidebar-header {
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
  writing-mode: horizontal-tb;
}

.sidebar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 56px;
  height: 56px;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: var(--space-xs);
}

.sidebar-btn:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-primary);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

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

.sidebar-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.sidebar-label {
  font-size: 9px;
  color: var(--color-text-light);
  font-weight: 500;
  text-align: center;
  line-height: 1.1;
}

.sidebar-btn.voice:hover { border-color: #e74c3c; }
.sidebar-btn.text:hover { border-color: #3498db; }
.sidebar-btn.media:hover { border-color: #2ecc71; }
.sidebar-btn.ai:hover {
  border-color: var(--color-primary);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
}

.sidebar-divider {
  width: 40px;
  height: 1px;
  background: var(--color-border);
  margin: var(--space-xs) 0;
}

/* Story Content Area (adjusted for sidebar) */
.story-modal-layout .story-modal-content {
  flex: 1;
  padding: var(--space-lg);
  max-width: none;
  margin: 0;
  overflow-y: auto;
}

/* Mobile: Convert sidebar to horizontal bar at bottom (v6.4.7) */
/* v6.4.8: Go Live button moves to top of modal on mobile */
/* v6.4.9: Fixed story content visibility issues on iPhone */
@media (max-width: 768px) {
  .story-modal-layout {
    display: block !important; /* v6.4.9: Use block instead of flex to fix iPhone layout */
    min-height: auto;
    padding-bottom: 85px; /* Space for bottom bar */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .story-sidebar {
    /* v6.4.7: Show as horizontal bar at bottom instead of hiding */
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    min-width: unset !important;
    height: 70px !important;
    max-height: 70px !important;
    flex-direction: row !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 8px 16px !important;
    gap: 12px !important;
    border-right: none !important;
    border-top: 1px solid var(--color-border) !important;
    background: var(--color-bg-primary) !important;
    z-index: 1000 !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
  }

  .story-sidebar .sidebar-header {
    display: none !important; /* Hide "Share" header on mobile */
  }

  .story-sidebar .sidebar-divider {
    display: none !important; /* Hide divider on mobile */
  }

  .story-sidebar .sidebar-btn {
    width: 50px !important;
    height: 50px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    flex-shrink: 0;
  }

  .story-sidebar .sidebar-label {
    font-size: 8px !important;
  }

  /* v6.4.8: Hide Go Live from bottom bar on mobile - it shows at top */
  .story-sidebar .sidebar-btn.live-mode {
    display: none !important;
  }

  .story-modal-layout .story-modal-content {
    padding: var(--space-md);
    display: block !important;
    min-height: 100%;
  }
}

/* v6.6.0: Story header controls container */
.story-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  position: absolute;
  top: 70px;
  right: 16px;
  z-index: 101;
}

/* v6.6.0: Story lock toggle button */
.story-lock-toggle {
  display: none; /* Hidden on desktop - use sidebar */
}

/* v6.6.0: Sidebar lock toggle styling */
.sidebar-lock-toggle.locked {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

.sidebar-lock-toggle.unlocked {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.sidebar-lock-toggle.locked .sidebar-icon,
.sidebar-lock-toggle.unlocked .sidebar-icon {
  font-size: 16px;
}

/* v6.4.8: Go Live floating button - hidden on desktop */
.story-go-live-mobile {
  display: none;
}

/* v6.4.8: Go Live floating button at top of story modal on mobile */
/* v6.6.0: Lock toggle also shown on mobile in header controls */
@media (max-width: 768px) {
  /* v6.6.0: Header controls positioning on mobile */
  .story-header-controls {
    position: fixed;
    top: 70px;
    right: 16px;
    z-index: 101;
    display: flex;
    gap: 8px;
  }

  /* v6.6.0: Lock toggle on mobile */
  .story-lock-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
  }

  .story-lock-toggle.locked {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  }

  .story-lock-toggle.unlocked {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  }

  .story-lock-toggle .lock-icon {
    font-size: 14px;
  }

  .story-lock-toggle .lock-text {
    font-size: 12px;
  }

  .story-go-live-mobile {
    display: flex; /* Show on mobile */
    position: static; /* Now inside flex container */
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    border: none;
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
    cursor: pointer;
    animation: goPulse 2s ease-in-out infinite;
  }

  .story-go-live-mobile::before {
    content: '●';
    color: white;
    animation: liveDot 1s ease-in-out infinite;
  }

  @keyframes goPulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4); }
    50% { box-shadow: 0 4px 20px rgba(220, 38, 38, 0.6); }
  }

  @keyframes liveDot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
  }
}

/* ============================================
   Story Lock Indicator on Cards (v6.6.0)
   ============================================ */

.story-lock-indicator {
  font-size: 0.85rem;
  margin-left: 4px;
  opacity: 0.8;
}

/* ============================================
   AI Modification Proposal Card (v6.7.0)
   ============================================ */

.modification-proposal-container {
  position: fixed;
  bottom: 100px;
  right: 20px;
  z-index: 10001;
  display: none;
  justify-content: flex-end;
  animation: slideInRight 0.3s ease-out;
}

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

.modification-proposal-card {
  background: linear-gradient(145deg, #1e3a5f 0%, #0d1b2a 100%);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 16px;
  padding: 16px;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
              0 0 16px rgba(99, 102, 241, 0.2);
}

.proposal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.proposal-action {
  font-size: 1rem;
  font-weight: 600;
  color: #a5b4fc;
}

.proposal-dismiss {
  background: transparent;
  border: none;
  color: #6b7280;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.proposal-dismiss:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #9ca3af;
}

.proposal-content {
  margin-bottom: 16px;
}

.proposal-rationale {
  color: #94a3b8;
  font-size: 0.85rem;
  margin: 0 0 8px 0;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border-left: 3px solid #6366f1;
}

.proposal-preview {
  color: #e2e8f0;
  font-size: 0.9rem;
  margin: 0 0 8px 0;
  line-height: 1.5;
}

.proposal-target {
  color: #64748b;
  font-size: 0.8rem;
  margin: 0;
}

.proposal-actions {
  display: flex;
  gap: 8px;
}

.btn-accept-proposal {
  flex: 1;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-accept-proposal:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-dismiss-proposal {
  background: rgba(255, 255, 255, 0.1);
  color: #9ca3af;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-dismiss-proposal:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #d1d5db;
}

/* Mobile responsive */
@media (max-width: 767px) {
  .modification-proposal-container {
    bottom: 80px;
    left: 10px;
    right: 10px;
  }

  .modification-proposal-card {
    max-width: none;
  }
}

/* ============================================
   AI Dialogue Lock Banner (v6.6.0)
   ============================================ */

.ai-dialogue-lock-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #fef3c7 0%, #fcd34d 100%);
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  color: #92400e;
  font-size: 0.9rem;
}

.ai-dialogue-lock-banner .lock-icon {
  font-size: 1.2rem;
}

.ai-dialogue-lock-banner .lock-text {
  flex: 1;
}

.ai-dialogue-container.story-locked {
  border: 2px solid #f59e0b;
}

.ai-dialogue-container.story-locked .ai-dialogue-header {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.15) 100%);
}

/* v7.3.0: Unlock banner (for editable stories) */
.ai-dialogue-unlock-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #d1fae5 0%, #6ee7b7 100%);
  border-bottom: 1px solid rgba(16, 185, 129, 0.3);
  color: #065f46;
  font-size: 0.9rem;
}

.ai-dialogue-unlock-banner .lock-icon {
  font-size: 1.2rem;
}

.ai-dialogue-unlock-banner .lock-text {
  flex: 1;
}

/* v7.3.0: Lock info toggle button */
.lock-info-toggle {
  background: transparent;
  border: none;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  margin-left: 8px;
}

.lock-info-toggle:hover {
  opacity: 0.8;
}

/* v7.3.0: Lock explanation panel */
.ai-dialogue-lock-explanation {
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
  line-height: 1.5;
}

.ai-dialogue-lock-explanation p {
  margin: 0 0 8px 0;
}

.ai-dialogue-lock-explanation p:last-child {
  margin-bottom: 0;
}

.ai-dialogue-lock-explanation ul {
  margin: 8px 0;
  padding-left: 20px;
}

.ai-dialogue-lock-explanation li {
  margin: 4px 0;
}

/* ============================================
   Commentary Panel (v6.6.0)
   ============================================ */

.story-commentary-section {
  margin-top: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-secondary);
  overflow: hidden;
}

.commentary-header {
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}

.commentary-header:hover {
  background: var(--color-bg-tertiary);
}

.commentary-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.commentary-toggle-icon {
  color: var(--color-text-light);
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}

.story-commentary-section.expanded .commentary-toggle-icon {
  transform: rotate(90deg);
}

.commentary-count-badge {
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--color-text-light);
}

.commentary-hint {
  margin: 4px 0 0 24px;
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.commentary-content {
  padding: 0 var(--space-lg) var(--space-lg);
  max-height: 400px;
  overflow-y: auto;
}

.commentary-loading,
.commentary-empty,
.commentary-error {
  padding: var(--space-md);
  text-align: center;
  color: var(--color-text-light);
  font-size: 0.9rem;
}

.commentary-empty-hint {
  font-size: 0.85rem;
  margin-top: 4px;
  opacity: 0.8;
}

.commentary-error a {
  color: var(--color-primary);
  text-decoration: underline;
}

.commentary-item {
  background: var(--color-bg-primary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  border: 1px solid var(--color-border);
}

.commentary-item:last-child {
  margin-bottom: 0;
}

.commentary-item-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.commentary-type-icon {
  font-size: 1rem;
}

.commentary-type-label {
  font-weight: 600;
  color: var(--color-text);
}

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

.commentary-timestamp {
  color: var(--color-text-lighter);
  font-size: 0.8rem;
  margin-left: auto;
}

.commentary-prompt {
  background: rgba(102, 126, 234, 0.08);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.commentary-prompt .prompt-label {
  color: var(--color-text-light);
  font-weight: 500;
}

.commentary-prompt .prompt-text {
  color: var(--color-text);
  font-style: italic;
}

.commentary-item-content {
  color: var(--color-text);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* AI Feedback styling */
.commentary-item.ai_feedback {
  border-left: 3px solid #667eea;
}

/* Family Comment styling */
.commentary-item.family_comment {
  border-left: 3px solid #10b981;
}

/* Note styling */
.commentary-item.note {
  border-left: 3px solid #f59e0b;
}

/* Mobile adjustments for commentary */
@media (max-width: 768px) {
  .commentary-content {
    padding: 0 var(--space-md) var(--space-md);
    max-height: 300px;
  }

  .commentary-header {
    padding: var(--space-sm) var(--space-md);
  }

  .commentary-hint {
    margin-left: 20px;
    font-size: 0.8rem;
  }

  .commentary-item-header {
    font-size: 0.8rem;
  }

  .commentary-timestamp {
    width: 100%;
    margin-left: 24px;
    margin-top: 2px;
  }
}

/* ============================================
   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;
}

/* v6.4.6: Fixed contribution modal - container needs position:fixed, content needs card styling */
.contribution-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1099;
  justify-content: center;
  align-items: center;
}

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

.contribution-modal-content {
  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;
  z-index: 1101;
  position: relative;
}

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

/* v6.5.3: Colorful gradient header for contribution modals */
.contribution-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: none;
}

.contribution-modal-header h3 {
  margin: 0;
  font-size: var(--font-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: white;
}

.contribution-modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 1.5rem;
  color: white;
  cursor: pointer;
  padding: var(--space-xs);
  line-height: 1;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.contribution-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  color: white;
}

.contribution-modal-body {
  padding: var(--space-lg);
}

/* v6.5.3: Modal footer styling */
.contribution-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.contribution-modal-footer .btn-cancel {
  padding: 10px 20px;
  border: 1px solid #d1d5db;
  background: white;
  color: #374151;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.contribution-modal-footer .btn-cancel:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.contribution-modal-footer .btn-submit {
  padding: 10px 24px;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.contribution-modal-footer .btn-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.contribution-modal-footer .btn-submit:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  box-shadow: none;
}

/* v6.5.3: Improved voice record button */
.voice-record-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.voice-record-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.voice-record-btn.recording {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
  animation: pulse-btn 1s infinite;
}

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

.voice-record-btn .record-icon {
  font-size: 1.2rem;
}

.voice-record-btn .record-icon.recording {
  color: #ef4444;
}

/* v6.5.3: Text input area styling */
.text-input-area textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.2s ease;
}

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

/* v6.5.3: Contribution type selector styling */
.contribution-type-selector {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid #f3f4f6;
}

.contribution-type-selector label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 8px;
}

.contribution-type-selector select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.contribution-type-selector select:focus {
  outline: none;
  border-color: #667eea;
}

/* 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);
}

/* v6.4.9: Add Media modal preview constraints */
.media-preview {
  position: relative;
  max-height: 250px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--color-bg-secondary);
  margin-top: var(--space-md);
}

.media-preview img,
#mediaPreviewImage {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
}

/* v6.4.9: Media annotation area */
.media-annotation-area {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px dashed var(--color-border);
}

.media-annotation-area label {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
}

.media-annotation-textarea {
  width: 100%;
  min-height: 80px;
  padding: var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--font-sm);
  resize: vertical;
}

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

.media-annotation-voice-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--font-sm);
  transition: all 0.2s;
}

.media-annotation-voice-btn:hover {
  background: var(--color-bg-tertiary);
}

.media-annotation-voice-btn.recording {
  background: #fee2e2;
  border-color: #ef4444;
  color: #ef4444;
}

.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;
}

/* ============================================================================
   v6.8.0 - Chat Mode Badge (Contribution/Commentary indicator)
   Shows current mode based on story lock state
   ============================================================================ */

.chat-mode-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: var(--font-sm);
  font-weight: 500;
  margin-bottom: 8px;
  width: fit-content;
  transition: all 0.3s ease;
}

.chat-mode-badge .mode-icon {
  font-size: 14px;
}

.chat-mode-badge .mode-text {
  letter-spacing: 0.3px;
}

/* Contribution Mode (unlocked) - Green */
.chat-mode-badge.contribution-mode {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(5, 150, 105, 0.15) 100%);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Commentary Mode (locked) - Gray */
.chat-mode-badge.commentary-mode {
  background: linear-gradient(135deg, rgba(156, 163, 175, 0.2) 0%, rgba(107, 114, 128, 0.15) 100%);
  color: #9ca3af;
  border: 1px solid rgba(156, 163, 175, 0.3);
}

/* Input area layout update for mode badge */
.story-chat-input-area {
  display: flex;
  flex-direction: column;
  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-area > .chat-mode-badge {
  margin-bottom: 0;
}

.story-chat-input-area > textarea {
  flex: 1;
}

.story-chat-input-area > .story-chat-send-btn {
  align-self: flex-end;
  position: absolute;
  right: var(--space-lg);
  bottom: calc(var(--space-md) + 44px + var(--space-sm));
}

/* Flex row for textarea + send button */
.story-chat-input-area {
  position: relative;
}

.story-chat-input-area > textarea {
  padding-right: 60px;
}

.story-chat-input-area > .story-chat-send-btn {
  position: absolute;
  right: calc(var(--space-lg) + 4px);
  bottom: calc(var(--space-md) + 4px);
}

/* AI Dialogue input area mode badge */
.ai-dialogue-input-area .chat-mode-badge {
  margin-bottom: 8px;
}

/* 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)
   v7.3.0: Updated to fill full app window area (below header, right of sidebar)
   ============================================================================= */

.ai-dialogue-modal {
  position: fixed;
  top: var(--nav-height);
  left: var(--side-nav-width);
  right: 0;
  bottom: 0;
  display: none;
  align-items: stretch;
  justify-content: stretch;
  z-index: 10001;
  padding: 0;
}

.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.5);
  backdrop-filter: blur(2px);
}

.ai-dialogue-container {
  position: relative;
  background: var(--color-bg);
  border-radius: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: none;
  animation: none;
}

.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: none; /* v7.3.0: No max-height, use flex layout */
  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: row;
  gap: var(--space-xs);
  align-items: stretch;
}

/* AI Dialogue Voice Button */
.ai-dialogue-voice {
  padding: var(--space-sm);
  background: var(--color-bg-tertiary, #f5f5f5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  transition: all 0.2s ease;
}

.ai-dialogue-voice:hover:not(:disabled) {
  background: var(--color-bg-secondary);
  border-color: var(--color-primary);
}

.ai-dialogue-voice:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-dialogue-voice.recording {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-color: #dc2626;
  animation: voice-recording-pulse 1.5s ease-in-out infinite;
}

.ai-dialogue-voice.recording .voice-icon {
  color: white;
}

.voice-icon.recording-pulse {
  color: white;
  animation: voice-icon-pulse 0.8s ease-in-out infinite;
}

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

@keyframes voice-icon-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.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 v7.3.0: Full-screen below half-height header */
@media (max-width: 640px) {
  .ai-dialogue-modal {
    top: calc(var(--nav-height) / 2);
    left: 0;
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  .ai-dialogue-container {
    border-radius: 0;
    max-height: none;
    height: 100%;
  }

  .ai-dialogue-messages {
    max-height: none;
    flex: 1;
  }

  .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 */
/* v7.3.6: CRITICAL FIX - Must respect nav-height to not overlap header */
.fm-modal:has(.fm-panel.active) {
  /* Override the centered popup positioning */
  top: var(--nav-height) !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  transform: none !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: calc(100vh - var(--nav-height)) !important;
  max-height: calc(100vh - var(--nav-height)) !important;
  border-radius: 0 !important;
}

/* Fallback for browsers that don't support :has() */
/* v7.3.6: Also respect nav-height in fallback */
@supports not selector(:has(*)) {
  .fm-modal {
    overflow: visible !important;
  }
  .fm-panel.active {
    position: fixed !important;
    top: var(--nav-height) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: calc(100vh - var(--nav-height)) !important;
  }
}

/* ============================================================================
   GLOBAL LIVE MODE BANNER (v5.3.0)
   ============================================================================ */

.global-live-mode-banner {
  position: fixed;
  top: 60px; /* Below top-nav */
  left: 0;
  right: 0;
  z-index: 9990;
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  padding: 0;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.global-live-mode-banner.active {
  transform: translateY(0);
  opacity: 1;
}

/* Body adjustment when live banner is showing */
body.has-live-banner .main-content {
  margin-top: 48px;
}

body.has-live-banner .side-nav {
  top: 108px; /* 60px nav + 48px banner */
}

body.has-live-banner .family-navigator {
  top: 108px;
}

.live-banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  max-width: 100%;
  gap: 12px;
}

.live-banner-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.live-banner-indicator.opted-out {
  opacity: 0.7;
}

.live-dot {
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 50%;
  animation: livePulse 1.5s ease-in-out infinite;
}

.live-banner-indicator.opted-out .live-dot {
  animation: none;
  opacity: 0.5;
}

@keyframes livePulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

.live-text {
  font-weight: 700;
  color: white;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.live-banner-info {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.live-story-title {
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.live-story-title:hover {
  text-decoration-style: solid;
}

.live-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.live-banner-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.live-banner-btn.opt-out {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.live-banner-btn.opt-out:hover {
  background: rgba(255, 255, 255, 0.3);
}

.live-banner-btn.opt-in {
  background: #10b981;
  color: white;
}

.live-banner-btn.opt-in:hover {
  background: #059669;
}

.live-banner-btn.close {
  background: rgba(0, 0, 0, 0.2);
  color: white;
}

.live-banner-btn.close:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Mobile responsive banner */
@media (max-width: 640px) {
  .global-live-mode-banner {
    top: 56px; /* Mobile nav height */
  }

  body.has-live-banner .main-content {
    margin-top: 44px;
  }

  body.has-live-banner .side-nav {
    top: 100px;
  }

  .live-banner-content {
    padding: 8px 12px;
    gap: 8px;
  }

  .live-text {
    font-size: 0.75rem;
  }

  .live-story-title {
    font-size: 0.85rem;
  }

  .live-banner-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
  }
}

/* ============================================================================
   STORY MODAL LIVE MODE BUTTON (v5.3.0)
   ============================================================================ */

.sidebar-btn.live-mode {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
  position: relative;
}

.sidebar-btn.live-mode::before {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  animation: livePulse 1.5s ease-in-out infinite;
}

.sidebar-btn.live-mode .sidebar-icon {
  color: white !important;
}

.sidebar-btn.live-mode .sidebar-label {
  color: white !important;
}

.sidebar-btn.live-mode:hover {
  transform: scale(1.05);
}

/* Live mode indicator on story cards */
.story-card-live-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #dc2626;
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  z-index: 10;
}

.story-card-live-indicator .live-dot-small {
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  animation: livePulse 1.5s ease-in-out infinite;
}

/* Start Live Mode checkbox in Create Story form */
.create-story-live-mode {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fecaca;
  border-radius: 12px;
  margin-top: 16px;
}

.create-story-live-mode input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #dc2626;
}

.create-story-live-mode label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}

.create-story-live-mode .live-mode-title {
  font-weight: 600;
  color: #dc2626;
  display: flex;
  align-items: center;
  gap: 6px;
}

.create-story-live-mode .live-mode-desc {
  font-size: 0.8rem;
  color: #6b7280;
}


/* Story Person Picker Modal (v5.3.4 Contextual Tagging) */
/* v7.3.5: Respects FAA header boundary */
.story-person-picker-modal {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1100;
  justify-content: center;
  align-items: center;
  padding: var(--space-md);
}

.story-person-picker-content {
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.story-person-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.story-person-picker-header h3 {
  margin: 0;
  font-size: var(--font-lg);
}

.btn-close-picker {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  font-size: var(--font-xl);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.story-person-picker-search {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.story-person-picker-search 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);
}

.story-person-picker-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm) 0;
  max-height: 300px;
}

.story-person-picker-item {
  display: flex;
  flex-direction: column;
  padding: var(--space-sm) var(--space-lg);
  cursor: pointer;
  transition: background 0.2s ease;
}

.story-person-picker-item:hover {
  background: var(--color-bg-secondary);
}

.story-person-picker-name {
  font-weight: 600;
  color: var(--color-text);
}

.story-person-picker-rel {
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.story-person-picker-empty {
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-text-light);
}

.story-person-picker-loading {
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-text-light);
}

.story-person-picker-context {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.story-person-picker-context label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 600;
  color: var(--color-text);
}

.story-person-picker-context 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);
  margin-bottom: var(--space-md);
}

.story-person-picker-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* v7.3.5: Grid-based person tagging */
.story-person-grid-content {
  max-width: 500px;
}

.story-person-picker-actions-top {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.story-person-picker-actions-top .btn-sm {
  padding: 4px 12px;
  font-size: var(--font-sm);
}

.story-tag-count {
  margin-left: auto;
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

.story-person-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-xs);
  padding: var(--space-md);
  overflow-y: auto;
  max-height: 300px;
}

.story-person-grid-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--color-bg);
}

.story-person-grid-item:hover {
  border-color: var(--color-primary);
  background: rgba(102, 126, 234, 0.05);
}

.story-person-grid-item.checked {
  border-color: var(--color-success);
  background: rgba(16, 185, 129, 0.1);
}

.story-person-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
}

.story-person-checkbox.checked {
  background: var(--color-success);
  border-color: var(--color-success);
}

.story-person-name {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-person-picker-footer {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  justify-content: flex-end;
  background: var(--color-bg-secondary);
}

/* Mobile: single column grid */
@media (max-width: 480px) {
  .story-person-picker-grid {
    grid-template-columns: 1fr;
  }
}

/* Story persons header with add button */
.story-persons-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.story-persons-header h3 {
  margin: 0;
}

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

.story-persons-empty {
  color: var(--color-text-light);
  font-style: italic;
  font-size: var(--font-sm);
  margin: var(--space-sm) 0;
}

/* Story chapters header with add button (v6.5.2, v6.5.4: improved mobile visibility) */
.story-chapters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
  gap: var(--space-sm);
  flex-wrap: nowrap;
}

.story-chapters-header h3 {
  margin: 0;
  flex-shrink: 1;
  min-width: 0;
}

.story-add-chapter-btn {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-sm);
  flex-shrink: 0;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--color-primary, #667eea), var(--color-primary-dark, #5a67d8));
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  min-width: fit-content;
}

.story-add-chapter-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.story-chapters-empty {
  color: var(--color-text-light);
  font-style: italic;
  font-size: var(--font-sm);
  margin: var(--space-sm) 0;
}

/* Add Chapter Modal (v6.5.2) */
.add-chapter-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
}

.add-chapter-modal.active {
  display: block;
}

.add-chapter-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.add-chapter-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

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

.add-chapter-modal-header h3 {
  margin: 0;
  font-size: var(--font-lg);
}

.add-chapter-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--color-text-light);
  padding: var(--space-xs);
  line-height: 1;
}

.add-chapter-modal-body {
  padding: var(--space-lg);
}

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

.add-chapter-form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-xs);
  color: var(--color-text);
}

.add-chapter-input-wrapper {
  display: flex;
  gap: var(--space-xs);
}

.add-chapter-input-wrapper input,
.add-chapter-input-wrapper textarea {
  flex: 1;
  padding: var(--space-sm);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-base);
  transition: border-color 0.2s;
}

.add-chapter-input-wrapper input:focus,
.add-chapter-input-wrapper textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.add-chapter-input-wrapper textarea {
  resize: vertical;
  min-height: 80px;
}

.add-chapter-voice-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.2s;
}

.add-chapter-voice-btn:hover {
  background: var(--color-bg-secondary);
}

.add-chapter-voice-btn.recording {
  background: #fee2e2;
  border-color: #ef4444;
  animation: pulse-recording 1s infinite;
}

@keyframes pulse-recording {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Chapter reorder list */
.add-chapter-reorder-section {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.add-chapter-reorder-section h4 {
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-base);
  color: var(--color-text);
}

.add-chapter-reorder-hint {
  font-size: var(--font-sm);
  color: var(--color-text-light);
  margin-bottom: var(--space-md);
}

.chapter-reorder-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chapter-reorder-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xs);
  cursor: grab;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.chapter-reorder-item:active {
  cursor: grabbing;
}

.chapter-reorder-item.dragging {
  opacity: 0.5;
  background: var(--color-bg-tertiary);
}

.chapter-reorder-item.drag-over {
  border-color: var(--color-primary);
  background: white;
}

.chapter-reorder-item.new-chapter {
  background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
  border: 2px dashed var(--color-primary);
}

.chapter-reorder-handle {
  color: var(--color-text-light);
  font-size: 16px;
  cursor: grab;
}

.chapter-reorder-number {
  width: 24px;
  height: 24px;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-sm);
  font-weight: 600;
}

.chapter-reorder-title {
  flex: 1;
  font-size: var(--font-base);
}

.chapter-reorder-item.new-chapter .chapter-reorder-title {
  font-weight: 600;
  color: var(--color-primary);
}

/* Modal footer */
.add-chapter-modal-footer {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  padding: var(--space-lg);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.add-chapter-modal-footer button {
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-base);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.add-chapter-cancel-btn {
  background: white;
  border: 2px solid var(--color-border);
  color: var(--color-text);
}

.add-chapter-cancel-btn:hover {
  background: var(--color-bg-secondary);
}

.add-chapter-submit-btn {
  background: var(--color-primary);
  border: 2px solid var(--color-primary);
  color: white;
}

.add-chapter-submit-btn:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

.add-chapter-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .story-person-picker-content {
    max-height: 90vh;
    margin: var(--space-sm);
  }

  .story-person-picker-list {
    max-height: 250px;
  }

  .add-chapter-modal-content {
    width: 95%;
    max-height: 90vh;
    margin: var(--space-sm);
  }

  .add-chapter-modal-header,
  .add-chapter-modal-body,
  .add-chapter-modal-footer {
    padding: var(--space-md);
  }
}

/* =============================================================================
   TRAINING HUB VIEW (v5.4.0)
   ============================================================================= */

/* View subtitle */
.view-subtitle {
  color: var(--color-text-light);
  font-size: var(--font-sm);
  margin-top: var(--space-xs);
}

/* Training Hub Overview Stats */
.training-hub-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.training-stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.training-stat-card .stat-icon {
  font-size: 2rem;
}

.training-stat-card .stat-info {
  display: flex;
  flex-direction: column;
}

.training-stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

.training-stat-card .stat-label {
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

/* Training Hub Sections */
.training-hub-section {
  margin-bottom: var(--space-xl);
}

.training-hub-section h3 {
  margin-bottom: var(--space-md);
  font-size: var(--font-lg);
  color: var(--color-text);
}

/* Filter Bar */
.training-filter-bar {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

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

.training-filter-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.training-filter-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* Members Grid */
.training-members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}

.training-member-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.training-member-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary-light);
}

.training-member-card.ready {
  border-color: var(--color-success);
  background: linear-gradient(135deg, white, #ecfdf5);
}

.training-member-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

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

.training-member-avatar .avatar-initial {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-primary);
}

.training-member-avatar .ready-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-size: 0.875rem;
}

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

.training-member-name {
  font-weight: 600;
  color: var(--color-text);
  display: block;
  margin-bottom: var(--space-xs);
}

.training-progress-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.training-progress-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.training-progress-row .progress-icon {
  font-size: 0.75rem;
  width: 16px;
}

.progress-bar-mini {
  flex: 1;
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

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

.training-progress-row .progress-count {
  font-size: 0.7rem;
  color: var(--color-text-light);
  width: 28px;
  text-align: right;
}

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

.training-member-action .action-arrow {
  font-size: 1.25rem;
}

/* Quick Actions */
.training-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-md);
}

.training-action-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--color-border);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-sm);
}

.training-action-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.training-action-card .action-icon {
  font-size: 2rem;
}

.training-action-card .action-title {
  font-weight: 600;
  color: var(--color-text);
}

.training-action-card .action-desc {
  font-size: var(--font-sm);
  color: var(--color-text-light);
}

/* Training Tips */
.training-tips-card {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-top: var(--space-xl);
}

.training-tips-card h3 {
  margin: 0 0 var(--space-md) 0;
  color: var(--color-text);
}

.training-tips-list {
  margin: 0;
  padding-left: var(--space-lg);
  color: var(--color-text);
}

.training-tips-list li {
  margin-bottom: var(--space-sm);
  line-height: 1.5;
}

.training-tips-list li:last-child {
  margin-bottom: 0;
}

/* Empty State */
.training-empty-state {
  text-align: center;
  padding: var(--space-xxl) var(--space-lg);
  color: var(--color-text-light);
}

.training-empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .training-hub-overview {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }

  .training-stat-card {
    padding: var(--space-md);
  }

  .training-stat-card .stat-value {
    font-size: 1.25rem;
  }

  .training-members-grid {
    grid-template-columns: 1fr;
  }

  .training-actions-grid {
    grid-template-columns: 1fr;
  }

  .training-filter-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-xs);
  }

  .training-filter-btn {
    flex-shrink: 0;
  }
}

/* ============================================================================
   v6.3.0: MY ACTIVITY / REVIEW & ROLLBACK STYLES
   ============================================================================ */

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

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  transition: all 0.2s ease;
}

.activity-item:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.activity-item.rolled-back {
  opacity: 0.6;
  background: var(--color-surface-alt);
}

.activity-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border-radius: var(--radius-md);
}

.activity-details {
  flex: 1;
  min-width: 0;
}

.activity-description {
  font-weight: 500;
  color: var(--color-text);
  word-break: break-word;
}

.activity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
  font-size: var(--font-sm);
}

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

.activity-status.rolled-back {
  color: var(--color-success);
  font-weight: 500;
}

.activity-warning {
  color: var(--color-warning);
  font-size: var(--font-xs);
}

.activity-undo-btn {
  flex-shrink: 0;
  padding: var(--space-xs) var(--space-sm);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-light);
  font-size: var(--font-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 70px;
}

.activity-undo-btn:hover {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: white;
}

.activity-pagination {
  text-align: center;
  padding: var(--space-md);
  color: var(--color-text-light);
  font-size: var(--font-sm);
}

/* v7.2.0: Blocked activity item state */
.activity-item.blocked {
  opacity: 0.7;
  background: var(--color-surface-alt);
}

.activity-blocked {
  color: var(--color-text-light);
  font-size: var(--font-xs);
  display: flex;
  align-items: center;
  gap: 4px;
}

.activity-cascade {
  color: var(--color-warning);
  font-size: var(--font-xs);
  background: rgba(245, 158, 11, 0.1);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.activity-blocked-btn {
  flex-shrink: 0;
  padding: var(--space-xs);
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.activity-blocked-btn:hover {
  opacity: 1;
}

/* v7.2.0: Undo Confirmation Modal */
.undo-confirm-modal {
  max-width: 400px;
  margin: auto;
}

.undo-primary-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

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

.undo-text {
  font-weight: 500;
  color: var(--color-text);
}

.undo-cascade-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.undo-cascade-warning p {
  margin: 0 0 var(--space-sm) 0;
  color: var(--color-warning);
  font-weight: 500;
}

.undo-cascade-list {
  margin: 0;
  padding-left: var(--space-lg);
  list-style: none;
}

.undo-cascade-list li {
  margin-bottom: var(--space-xs);
  font-size: var(--font-sm);
  color: var(--color-text);
}

.undo-cascade-list li::before {
  content: "•";
  margin-right: var(--space-xs);
  color: var(--color-warning);
}

.undo-warning-text {
  color: var(--color-text-light);
  font-size: var(--font-sm);
  margin: 0;
  text-align: center;
}

/* v7.2.0: Blocked Explanation Modal */
.blocked-modal {
  max-width: 400px;
  margin: auto;
}

.blocked-contributors {
  margin-bottom: var(--space-md);
}

.blocked-contributors p {
  margin: 0 0 var(--space-sm) 0;
  color: var(--color-text);
}

.blocked-list {
  margin: 0;
  padding-left: var(--space-lg);
  list-style: none;
}

.blocked-list li {
  margin-bottom: var(--space-xs);
  font-size: var(--font-sm);
  color: var(--color-text);
}

.blocked-list li::before {
  content: "•";
  margin-right: var(--space-xs);
  color: var(--color-primary);
}

.blocked-reason {
  text-align: center;
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.blocked-help-text {
  color: var(--color-text-light);
  font-size: var(--font-sm);
  text-align: center;
  margin: var(--space-md) 0 0 0;
}

/* Danger button style */
.btn-danger {
  background: var(--color-danger);
  color: white;
  border: none;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Mobile adjustments */
@media (max-width: 768px) {
  .activity-item {
    flex-wrap: wrap;
    padding: var(--space-sm);
    gap: var(--space-sm);
  }

  .activity-icon {
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
  }

  .activity-undo-btn {
    width: 100%;
    margin-top: var(--space-sm);
    padding: var(--space-sm);
    min-height: 44px;
  }

  .activity-blocked-btn {
    width: auto;
    margin-top: var(--space-sm);
  }

  .undo-confirm-modal,
  .blocked-modal {
    max-width: 100%;
    margin: var(--space-md);
  }
}

/* ============================================================================
   DESKTOP WINDOWING SYSTEM (v7.0.0)
   ============================================================================

   On desktop screens (≥1024px), the sidebar is always visible.
   Full-screen modals should respect the sidebar and render in the
   "application window" area to the right of the sidebar.

   This creates a professional desktop app experience where users can:
   - See navigation at all times
   - Switch between apps without closing modals
   - Use horizontal space efficiently on wide screens

   On mobile (<1024px), modals remain full-viewport as before.
   ============================================================================ */

@media (min-width: 1024px) {
  /* v7.0.0: Desktop windowing - modals render beside sidebar, not over it */

  /* Family Member Modal - render in app window */
  .family-member-modal {
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    max-width: none !important;
    transform: none !important;
  }

  /* Family Member Modal backdrop - also respect sidebar */
  #fmModalBackdrop.active {
    left: var(--side-nav-width);
    width: calc(100% - var(--side-nav-width));
  }

  /* v7.3.5: All modals must respect FAA header boundary */
  /* Mobile Modal (used for training photos, documents, AI review) - render in app window */
  .mobile-modal {
    top: var(--nav-height) !important;
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    max-width: none !important;
    max-height: calc(100vh - var(--nav-height)) !important;
    transform: none !important;
  }

  /* Story Modal - render in app window */
  .story-modal,
  .story-detail-modal {
    top: var(--nav-height) !important;
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    max-width: none !important;
    max-height: calc(100vh - var(--nav-height)) !important;
    transform: none !important;
  }

  /* AI Document Analysis Modal - render in app window */
  .ai-modal-fullscreen {
    top: var(--nav-height) !important;
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    max-width: none !important;
    max-height: calc(100vh - var(--nav-height)) !important;
    transform: none !important;
  }

  /* Voice Training Modal - render in app window */
  .voice-training-modal {
    top: var(--nav-height) !important;
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    max-width: none !important;
    max-height: calc(100vh - var(--nav-height)) !important;
    transform: none !important;
  }

  /* Training Photo Modal - render in app window */
  .training-photo-modal {
    top: var(--nav-height) !important;
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    max-width: none !important;
    max-height: calc(100vh - var(--nav-height)) !important;
    transform: none !important;
  }

  /* Document Upload Modal - render in app window */
  .document-upload-modal {
    top: var(--nav-height) !important;
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    max-width: none !important;
    max-height: calc(100vh - var(--nav-height)) !important;
    transform: none !important;
  }

  /* Photo Source Modal - render in app window */
  .photo-source-modal-overlay {
    top: var(--nav-height) !important;
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    height: calc(100vh - var(--nav-height)) !important;
  }

  /* Media Modal (photo viewer) - render in app window */
  .media-modal-overlay {
    top: var(--nav-height) !important;
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    height: calc(100vh - var(--nav-height)) !important;
  }

  /* Feedback Modal - render in app window */
  .feedback-modal-overlay {
    top: var(--nav-height) !important;
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    height: calc(100vh - var(--nav-height)) !important;
  }

  /* Generic modal-overlay class - render in app window */
  .modal-overlay {
    top: var(--nav-height) !important;
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    height: calc(100vh - var(--nav-height)) !important;
  }

  /* Archive Chat - position relative to app window */
  .archive-chat {
    right: 20px;
    /* Already positioned correctly, no change needed */
  }

  /* Login overlay should still cover full screen (before authentication) */
  .login-overlay {
    left: 0 !important;
    width: 100% !important;
  }

  /* Generic modal backdrops - respect sidebar */
  .modal-backdrop-windowed {
    left: var(--side-nav-width);
    width: calc(100% - var(--side-nav-width));
  }

  /* Ensure sidebar stays above modals (z-index management) */
  .side-nav {
    z-index: 10001;
  }

  /* v7.0.1: FM Modal desktop windowing - compact popup is larger on desktop */
  .fm-modal {
    max-width: 500px;  /* Larger than mobile (315px) so all tiles visible without scroll */
    max-height: 90vh;
  }

  /* v7.0.1: FM Modal backdrop - respect sidebar on desktop */
  .fm-modal-backdrop {
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
  }

  /* v7.0.1: FM Modal with panel active - override fullscreen to respect sidebar */
  .fm-modal:has(.fm-panel.active) {
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    max-width: calc(100% - var(--side-nav-width)) !important;
  }

  /* v7.0.1: Fallback for browsers without :has() - panels respect sidebar */
  @supports not selector(:has(*)) {
    .fm-panel.active {
      left: var(--side-nav-width) !important;
      width: calc(100% - var(--side-nav-width)) !important;
    }
  }

  /* v7.3.0: CRITICAL - All modals and overlays must respect header height */
  /* Desktop: modals render within app window (below header, right of sidebar) */
  .modal-overlay,
  .fm-modal-backdrop,
  .leaderboard-hero-overlay,
  .leaderboard-hero-side-by-side,
  .ai-dialogue-modal,
  .contribution-modal,
  .photo-source-modal-overlay,
  .media-modal-overlay,
  .feedback-modal-overlay {
    top: var(--nav-height) !important;
  }

  /* v7.3.1: AI Dialogue Modal - render in app window (below header, right of sidebar) */
  .ai-dialogue-modal {
    left: var(--side-nav-width) !important;
    width: calc(100% - var(--side-nav-width)) !important;
    height: calc(100vh - var(--nav-height)) !important;
  }
}

/* ============================================================================
   v7.3.0: Mobile Modal Positioning - Half-Height Header
   Mobile devices use a smaller header, modals respect this
   ============================================================================ */
@media (max-width: 767px) {
  /* Mobile: half-height header */
  :root {
    --mobile-nav-height: calc(var(--nav-height) / 2);
  }

  /* Mobile header is half-height */
  .top-nav {
    height: calc(var(--nav-height) / 2);
  }

  /* Main content respects half-height header */
  .main-content {
    margin-top: calc(var(--nav-height) / 2);
    margin-left: 0;
  }

  /* All modal overlays and backdrops respect half-height header on mobile */
  .modal-overlay,
  .fm-modal-backdrop,
  .leaderboard-hero-overlay,
  .ai-dialogue-modal,
  .contribution-modal,
  .photo-source-modal-overlay,
  .media-modal-overlay,
  .feedback-modal-overlay {
    top: calc(var(--nav-height) / 2) !important;
    left: 0 !important;
    width: 100% !important;
  }

  /* FM modal full-screen but below header */
  .fm-modal {
    top: calc(var(--nav-height) / 2) !important;
    height: calc(100vh - var(--nav-height) / 2) !important;
  }

  /* v7.3.6: Mobile panels must also respect half-height header */
  .fm-modal:has(.fm-panel.active) {
    top: calc(var(--nav-height) / 2) !important;
    height: calc(100vh - var(--nav-height) / 2) !important;
  }

  .fm-panel.active {
    top: calc(var(--nav-height) / 2) !important;
    height: calc(100vh - var(--nav-height) / 2) !important;
  }
}
