/* =====================================================
   DYNAMIC Surgical Training App — Modern UI
   Clean, professional medical application design
   ===================================================== */

/* ─── Google Fonts injected via index.html ─── */

/* ─── Design Tokens ─── */
:root {
  /* Primary palette */
  --primary:        #2563eb;
  --primary-light:  #3b82f6;
  --primary-dark:   #1d4ed8;
  --primary-50:     #eff6ff;
  --primary-100:    #dbeafe;

  /* Accent */
  --accent:         #6366f1;
  --accent-light:   #818cf8;

  /* Semantic colours */
  --success:        #059669;
  --success-light:  #d1fae5;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --danger:         #dc2626;
  --danger-light:   #fee2e2;
  --info:           #0891b2;
  --info-light:     #cffafe;

  /* Neutrals */
  --surface:        #f8fafc;
  --surface-raised: #ffffff;
  --border:         #e2e8f0;
  --border-hover:   #cbd5e1;
  --text:           #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;

  /* Shadows */
  --shadow-sm:      0 1px 2px rgba(0,0,0,0.05);
  --shadow:         0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg:      0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl:      0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);

  /* Radii */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  /* Transitions */
  --ease:       cubic-bezier(0.4, 0, 0.2, 1);
  --duration:   0.2s;

  /* Spacing */
  --touch-target-size: 44px;

  /* Legacy aliases (keep for any JS/Bootstrap that reads them) */
  --primary-color:   var(--primary-dark);
  --secondary-color: var(--primary);
  --success-color:   var(--success);
  --warning-color:   var(--warning);
  --danger-color:    var(--danger);
  --info-color:      var(--info);
  --light-color:     var(--surface);
  --dark-color:      var(--text);
}

/* ─── Base Styles ─── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Fix iOS Safari 100vh issue */
  height: -webkit-fill-available;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--surface);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* iOS safe areas */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  /* Fix iOS Safari 100vh */
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  /* Prevent pull-to-refresh interfering with scroll */
  overscroll-behavior-y: none;
  /* Smooth momentum scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* ─── Touch-Friendly Targets ─── */
.btn, .nav-link, .form-control, .form-select {
  min-height: var(--touch-target-size);
}

/* iOS form element fixes */
input, textarea, select, button {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: 0;
}

/* Re-apply border-radius after resetting appearance */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="tel"],
textarea,
select {
  border-radius: var(--radius);
}

input[type="checkbox"],
input[type="radio"] {
  -webkit-appearance: checkbox;
  -moz-appearance: checkbox;
  appearance: checkbox;
}

/* Prevent iOS zoom on input focus (font-size >= 16px) */
@media screen and (max-width: 768px) {
  input, textarea, select {
    font-size: 16px !important;
  }
}

/* Tap highlight removal for iOS */
a, button, .btn, .nav-link, .card, .list-group-item {
  -webkit-tap-highlight-color: transparent;
}

/* Touch action for better scroll performance */
.list-group, .sessions-list, .card-body {
  touch-action: pan-y;
}

/* ─── Dashboard Visibility Toggle ─── */
.dashboard-header-stats {
  display: none;
}
body.on-dashboard .dashboard-header-stats {
  display: block;
}

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.btn {
  padding: 10px 20px;
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  transition: all var(--duration) var(--ease);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--touch-target-size);
  line-height: 1.5;
}

.btn:hover, .btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus-visible {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover, .btn-outline-primary:focus-visible {
  background: var(--primary);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover { background: #047857; border-color: #047857; color: #fff; }

.btn-outline-success {
  background: transparent; color: var(--success); border-color: var(--success);
}
.btn-outline-success:hover { background: var(--success); color: #fff; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }

.btn-outline-danger {
  background: transparent; color: var(--danger); border-color: var(--danger);
}
.btn-outline-danger:hover { background: var(--danger); color: #fff; }

.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}
.btn-warning:hover { background: #b45309; border-color: #b45309; color: #fff; }

.btn-outline-warning {
  background: transparent; color: var(--warning); border-color: var(--warning);
}
.btn-outline-warning:hover { background: var(--warning); color: #fff; }

.btn-info {
  background: var(--info);
  color: #fff;
  border-color: var(--info);
}
.btn-info:hover { background: #0e7490; border-color: #0e7490; color: #fff; }

.btn-outline-info {
  background: transparent; color: var(--info); border-color: var(--info);
}
.btn-outline-info:hover { background: var(--info); color: #fff; }

.btn-secondary {
  background: #64748b;
  color: #fff;
  border-color: #64748b;
}
.btn-secondary:hover { background: #475569; border-color: #475569; color: #fff; }

.btn-outline-secondary {
  background: transparent; color: #64748b; border-color: #94a3b8;
}
.btn-outline-secondary:hover { background: #64748b; color: #fff; border-color: #64748b; }

.btn-outline-light {
  background: transparent; color: rgba(255,255,255,0.9); border-color: rgba(255,255,255,0.4);
}
.btn-outline-light:hover { background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.7); }

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  min-height: 36px;
}

/* ═══════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════ */
header {
  background: var(--primary-dark) !important;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1020;
  /* iOS safe area support */
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

header h1 {
  font-weight: 700;
  letter-spacing: -0.025em;
  font-size: 1.15rem;
}

/* ═══════════════════════════════════════════
   NAVIGATION
   ═══════════════════════════════════════════ */
.navbar {
  padding: 6px 0;
  background-color: var(--surface-raised) !important;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 56px; /* header height */
  z-index: 1019;
}

.navbar-toggler {
  border: 1.5px solid var(--primary-100) !important;
  background-color: var(--surface-raised);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.2);
}

.navbar-toggler-icon {
  background-image: none !important;
  width: 22px;
  height: 2px;
  background-color: var(--primary-dark);
  border-radius: 2px;
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.navbar-toggler-icon::before,
.navbar-toggler-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 22px;
  height: 2px;
  background-color: var(--primary-dark);
  border-radius: 2px;
}

.navbar-toggler-icon::before {
  top: -6px;
}

.navbar-toggler-icon::after {
  top: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px !important;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-secondary) !important;
  text-decoration: none;
  transition: all var(--duration) var(--ease);
  border-radius: var(--radius);
  margin: 2px 4px;
  gap: 0.4rem;
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2.5px;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: all var(--duration) var(--ease);
  transform: translateX(-50%);
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--primary) !important;
  background-color: var(--primary-50);
}

.nav-link:hover::after {
  width: 60%;
}

.nav-link.active {
  color: var(--primary) !important;
  background-color: var(--primary-50);
  font-weight: 600;
}

.nav-link.active::after {
  width: 70%;
}

.nav-link i {
  font-size: 1rem;
}

/* ═══════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════ */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: all var(--duration) var(--ease);
  overflow: hidden;
  background: var(--surface-raised);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.card-header {
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.card-header h3,
.card-header .h6,
.card-header .h5 {
  color: var(--text);
  margin-bottom: 0;
  font-weight: 700;
}

.card-body {
  padding: 1.25rem;
}

/* ─── Back Arrow Button ─── */
.back-arrow-btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 6px 10px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
}

.back-arrow-btn:hover {
  background: var(--primary-50);
  border-color: var(--primary-light);
  color: var(--primary);
  transform: translateX(-2px);
}

.back-arrow-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.back-arrow-btn i {
  font-size: 1.1rem;
  font-weight: 700;
  display: block;
  line-height: 1;
}

/* ═══════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════ */
.form-control,
.form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface-raised);
  transition: all var(--duration) var(--ease);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  outline: none;
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control-lg {
  padding: 14px 18px;
  font-size: 1rem;
}

.form-label {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.form-check-label {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════
   SECTION TRANSITIONS
   ═══════════════════════════════════════════ */
.app-section {
  animation: fadeIn 0.35s var(--ease);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════
   DASHBOARD STAT CARDS
   ═══════════════════════════════════════════ */
.dashboard-card {
  background: var(--surface-raised);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: all var(--duration) var(--ease);
  text-align: center;
}

.dashboard-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-100);
}

.dashboard-card i {
  margin-bottom: 0.75rem;
}

/* Stat cards (dashboard section) */
.dashboard-header-stats .card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--duration) var(--ease);
}

.dashboard-header-stats .card:hover {
  border-color: var(--primary-100);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.dashboard-header-stats .card .card-body {
  padding: 1.25rem 1rem;
}

.dashboard-header-stats .card .display-6 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.dashboard-header-stats .card .card-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

/* ─── Empty States ─── */
.text-muted {
  color: var(--text-muted) !important;
}

.empty-state {
  padding: 3rem 1rem;
  text-align: center;
}

.empty-state i {
  opacity: 0.4;
  margin-bottom: 1rem;
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
   ═══════════════════════════════════════════ */

/* --- Base mobile styles (default, no query) --- */
.container {
  padding-left: 12px;
  padding-right: 12px;
}

header h1 { font-size: 1rem; }

.navbar {
  top: calc(46px + env(safe-area-inset-top));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.navbar-nav { padding: 8px 0; }

.nav-link {
  padding: 12px 10px !important;
  margin: 4px 2px;
  font-size: 0.85rem;
}

.card-body { padding: 1rem; }

.btn {
  width: 100%;
  margin-bottom: 8px;
}
.btn:last-child { margin-bottom: 0; }

.display-6 { font-size: 1.75rem; }

header .py-3 { padding-top: 0.6rem !important; padding-bottom: 0.6rem !important; }

/* Extra-small screens */
@media (max-width: 576px) {
  .nav-link {
    flex-direction: column;
    padding: 10px 8px !important;
    font-size: 0.75rem;
  }
  .nav-link i {
    font-size: 1.1rem;
    margin-bottom: 3px;
  }
  .card-title { font-size: 0.85rem; }
  header h1 { font-size: 0.95rem; padding: 0 10px; }

  .session-actions .btn {
    flex: 1 1 100%;
  }
}

@media (max-width: 768px) {
  .btn-sm {
    min-height: var(--touch-target-size);
    padding: 10px 14px;
    font-size: 0.875rem;
  }

  .back-arrow-btn {
    min-width: var(--touch-target-size);
    min-height: var(--touch-target-size);
    padding: 8px 12px;
  }

  .navbar-toggler,
  .btn-close {
    min-width: var(--touch-target-size);
    min-height: var(--touch-target-size);
  }

  .session-actions {
    flex-wrap: wrap;
  }

  .session-actions .btn {
    min-height: var(--touch-target-size);
    font-size: 0.875rem;
    padding: 10px 14px;
    flex: 1 1 calc(50% - 4px);
  }

  .session-export-actions {
    display: none !important;
  }
}

/* --- Tablet and up --- */
@media (min-width: 769px) {
  .container {
    padding-left: 24px;
    padding-right: 24px;
  }

  header h1 { font-size: 1.15rem; }

  .nav-link {
    padding: 10px 16px !important;
    font-size: 0.875rem;
  }

  .card-body { padding: 1.25rem; }

  .btn {
    width: auto;
    margin-bottom: 0;
  }

  .display-6 { font-size: 2rem; }
}

/* Landscape on short screens */
@media (max-height: 500px) and (orientation: landscape) {
  header { position: relative; }
  .navbar { position: relative; top: 0; }
  .py-4 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
}

/* Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .btn, .card, .form-control { border-width: 0.5px; }
}

/* ─── iOS Safe Area Bottom Padding ─── */
/* Ensure content isn't hidden behind home indicator or toolbar */
main.container-fluid,
main.container {
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

/* Bottom-of-screen modals & prompts respect safe area */
.modal-dialog {
  padding-bottom: env(safe-area-inset-bottom);
}

/* ─── iOS Standalone PWA Adjustments ─── */
@media (display-mode: standalone) {
  header {
    padding-top: env(safe-area-inset-top);
  }
  
  .landing-nav {
    padding-top: calc(14px + env(safe-area-inset-top));
  }
  
  body {
    /* Prevent rubber-banding in standalone */
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  
  .container-fluid {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ─── iOS-specific fixes via @supports ─── */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari specific */
  body {
    /* Prevent text size adjustment */
    -webkit-text-size-adjust: 100%;
  }
  
  /* Fix iOS input zoom — ensure 16px font minimum */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="url"],
  input[type="number"],
  input[type="search"],
  input[type="tel"],
  textarea,
  select {
    font-size: max(16px, 1em);
  }
  
  /* Fix momentum scrolling in overflow containers */
  .sessions-list,
  .list-group,
  .modal-body,
  .card-body {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Fix sticky positioning in iOS Safari */
  header,
  .navbar {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  /* Larger slider thumbs for touch on iOS */
  .skill-slider::-webkit-slider-thumb,
  .tlx-slider::-webkit-slider-thumb {
    width: 34px;
    height: 34px;
  }
  
  /* Fix button alignment on iOS */
  .btn-group > .btn {
    -webkit-appearance: none;
    appearance: none;
  }
}

/* ─── Accessibility ─── */
.btn:focus-visible,
.nav-link:focus-visible,
.form-control:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════
   DARK MODE
   ═══════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  :root {
    --surface:        #0f172a;
    --surface-raised: #1e293b;
    --border:         #334155;
    --border-hover:   #475569;
    --text:           #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted:     #64748b;
    --primary-50:     rgba(37,99,235,0.15);
    --primary-100:    rgba(37,99,235,0.25);
    --shadow-sm:      0 1px 2px rgba(0,0,0,0.3);
    --shadow:         0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md:      0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
    --shadow-lg:      0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
  }

  body {
    background-color: var(--surface);
    color: var(--text);
  }

  .card {
    background-color: var(--surface-raised);
    color: var(--text);
  }

  .navbar {
    background-color: var(--surface-raised) !important;
    border-color: var(--border);
  }

  .nav-link {
    color: var(--text-secondary) !important;
  }

  .form-control,
  .form-select {
    background-color: var(--surface);
    border-color: var(--border);
    color: var(--text);
  }

  .form-control:focus,
  .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
  }

  .card-header {
    background: var(--surface-raised);
    border-color: var(--border);
  }

  header {
    background: #0f172a !important;
  }

  .btn-outline-primary {
    color: var(--primary-light);
    border-color: var(--primary-light);
  }

  .stat-card {
    background: var(--surface-raised) !important;
  }

  .session-card { background: var(--surface-raised); border-color: var(--border); }
  .session-info-card { background: var(--surface); }
  .session-summary { background: var(--surface); }
  .constraint-checkbox { background: var(--surface); border-color: var(--border); }
  .skill-description,
  .tlx-description,
  .overall-rating-description { background: var(--surface); color: var(--text-secondary); }
  .technical-skill-item,
  .nasa-tlx-item { border-color: var(--border); }
  .session-notes,
  .session-reflection { background: var(--surface); color: var(--text-secondary); }
  .assessment-item { background: var(--surface); }

  .dashboard-header-stats .card .display-6 {
    background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  .constraint-buttons { background-color: var(--surface) !important; }
  .constraint-btn { background-color: var(--surface-raised); border-color: var(--border); color: var(--text-secondary); }
  .bg-light { background-color: var(--surface) !important; }
  #sessionTimer { background: rgba(0,0,0,0.3); }
}

/* Timer controls sticky - with iOS safe area */
.timer-controls-sticky {
  position: sticky;
  top: 0;
  background: var(--surface-raised);
  z-index: 100;
  padding: 15px 0;
  border-bottom: 2px solid var(--success);
  margin-bottom: 20px;
}

/* ═══════════════════════════════════════════
   PWA PROMPT
   ═══════════════════════════════════════════ */
.pwa-prompt {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 20px;
  right: 20px;
  background: var(--surface-raised);
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  z-index: 1030;
  display: none;
}

.pwa-prompt.show {
  display: block;
  animation: slideUp 0.3s var(--ease);
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ═══════════════════════════════════════════
   AUTH FORMS
   ═══════════════════════════════════════════ */
.auth-form {
  transition: all var(--duration) var(--ease);
}

/* Login/Register card */
#login-section .card {
  border: none;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-xl);
}

#login-section .card-body {
  padding: 2rem;
}

/* ─── Button Groups ─── */
.btn-group {
  display: flex;
  gap: 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.btn-group .btn {
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}

.btn-group .btn:first-child {
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}

.btn-group .btn:last-child {
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

@media (max-width: 768px) {
  .auth-form .form-control-lg {
    padding: 12px 14px;
    font-size: 1rem;
    border-radius: var(--radius);
  }
  .auth-form .btn-lg {
    padding: 14px 20px;
    font-size: 1rem;
  }
  .form-check-input {
    width: 1.2em;
    height: 1.2em;
  }
  .form-check-label {
    padding-left: 6px;
    font-size: 0.85rem;
  }
}

/* ═══════════════════════════════════════════
   CONSTRAINT CATEGORIES
   ═══════════════════════════════════════════ */
.constraint-category {
  margin-bottom: 0.75rem;
}

.category-header {
  cursor: pointer;
  user-select: none;
  transition: all var(--duration) var(--ease);
}

.category-header:hover {
  opacity: 0.85;
}

.category-header .collapse-icon {
  transition: transform 0.25s var(--ease);
}

.category-header[aria-expanded="false"] .collapse-icon {
  transform: rotate(-90deg);
}

.category-header .bg-light {
  border-radius: var(--radius) !important;
  border: 1px solid var(--border);
}

.constraint-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-top: none !important;
  border-radius: 0 0 var(--radius) var(--radius);
}

.constraint-btn {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background-color: var(--surface-raised);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.constraint-btn:hover {
  border-color: var(--border-hover);
  background-color: var(--surface);
}

.constraint-btn.selected {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.constraint-btn.selected:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
}

.constraint-btn .check-icon {
  display: none;
  font-size: 0.75rem;
}

.constraint-btn.selected .check-icon {
  display: inline;
}

/* Category-specific colours */
.surgical-constraint.selected {
  background-color: var(--danger);
  border-color: var(--danger);
}
.surgical-constraint.selected:hover {
  background-color: #b91c1c;
  border-color: #b91c1c;
}

.circumstantial-constraint.selected {
  background-color: var(--warning);
  border-color: var(--warning);
  color: #fff;
}
.circumstantial-constraint.selected:hover {
  background-color: #b45309;
  border-color: #b45309;
}

.personnel-constraint.selected {
  background-color: var(--info);
  border-color: var(--info);
}
.personnel-constraint.selected:hover {
  background-color: #0e7490;
  border-color: #0e7490;
}

/* ═══════════════════════════════════════════
   NASA-TLX DISPLAY (Session History)
   ═══════════════════════════════════════════ */
.nasa-tlx-grid {
  margin-top: 10px;
  padding-right: 40px;
}

.tlx-item {
  margin-bottom: 8px;
  position: relative;
}

.tlx-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2px;
  font-weight: 500;
}

.tlx-bar-container {
  position: relative;
  background: var(--border);
  height: 22px;
  border-radius: var(--radius-sm);
  overflow: visible;
  display: flex;
  align-items: center;
}

.tlx-bar {
  height: 100%;
  transition: width 0.4s var(--ease);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.tlx-bar-container .tlx-value {
  position: absolute;
  right: -30px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-raised);
  padding: 0 4px;
  white-space: nowrap;
}

/* Technical Skills Display */
.skill-value-container {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--primary);
  margin-left: 10px;
}

.skill-value-label {
  color: var(--text-muted);
  font-weight: normal;
}

.skill-value {
  font-size: 1.2rem;
}

.skill-value-max {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* NASA-TLX Assessment Page */
.tlx-value-container {
  display: block;
  text-align: center;
  margin: 12px 0;
  padding: 8px;
  background: var(--primary-50);
  border-radius: var(--radius);
}

.tlx-value-label {
  color: var(--text-muted);
  font-weight: normal;
  font-size: 0.85rem;
}

.tlx-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
}

.tlx-value-max {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ═══════════════════════════════════════════
   LOADING STATES
   ═══════════════════════════════════════════ */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════
   NAVIGATION VIEW CARDS
   (Specialty, Procedure, Subprocedure, Simulation)
   ═══════════════════════════════════════════ */
.specialty-card,
.procedure-card,
.subprocedure-card {
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  border-left: 3px solid transparent;
  border-radius: 0;
}

.specialty-card:hover,
.procedure-card:hover,
.subprocedure-card:hover {
  background-color: var(--primary-50);
  border-left-color: var(--primary);
}

.specialty-icon {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border-radius: var(--radius);
  margin-right: 1rem;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.specialty-content,
.procedure-content,
.subprocedure-content {
  flex-grow: 1;
}

.specialty-title,
.procedure-title,
.subprocedure-title {
  font-weight: 600;
  margin-bottom: 0.2rem;
  color: var(--text);
  font-size: 0.9375rem;
}

.specialty-meta,
.procedure-meta,
.subprocedure-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.procedure-description,
.subprocedure-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

/* Simulation Items */
.simulation-item {
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  background-color: var(--surface-raised);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration) var(--ease);
}

.simulation-item:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-100);
  transform: translateY(-1px);
}

.simulation-item:last-child { margin-bottom: 0; }

.simulation-title {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.4rem;
  font-size: 1.05rem;
}

.simulation-description {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.simulation-instructions {
  background-color: var(--primary-50);
  padding: 0.875rem;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  border-left: 3px solid var(--primary);
}

.simulation-instructions strong {
  color: var(--primary);
}

.simulation-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.simulation-meta-item {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.simulation-meta-item i { margin-right: 0.4rem; }

.simulation-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  min-height: 28px;
}

/* ─── Bookmark Indicator ─── */
.bookmark-indicator {
  color: var(--danger);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.bookmark-indicator:hover { color: #b91c1c; transform: scale(1.15); }
.bookmark-indicator.active { color: var(--danger); }
.bookmark-indicator.inactive { color: var(--text-muted); }

/* Search highlighting */
.search-highlight {
  background-color: var(--warning-light);
  padding: 0.1rem 0.2rem;
  border-radius: 3px;
}

/* Filter states */
.filtered-item { display: block !important; }
.hidden-item { display: none !important; }

/* ═══════════════════════════════════════════
   RECENT ACTIVITY
   ═══════════════════════════════════════════ */
.activity-item {
  padding: 0.875rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background var(--duration) var(--ease);
}
.activity-item:hover { background-color: var(--surface); }
.activity-item:last-child { border-bottom: none; }

.activity-content { flex-grow: 1; }

.activity-title {
  font-weight: 600;
  margin-bottom: 0.15rem;
  font-size: 0.9375rem;
}

.activity-details {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  margin-left: 1rem;
}

/* Mobile navigation views */
@media (max-width: 768px) {
  .procedure-navigator { max-height: 400px; }
  .specialty-header { padding: 0.75rem; }
  .procedure-header { padding: 0.5rem 0.75rem 0.5rem 1.5rem; }
  .subprocedure-header { padding: 0.5rem 0.75rem 0.5rem 2.25rem; }
  .simulation-list { padding: 0.5rem 0.75rem 0.5rem 3rem; }
  .simulation-actions { flex-direction: column; }
  .procedure-actions { flex-direction: column; gap: 0.25rem; }
}

/* ═══════════════════════════════════════════
   PRACTICE SETUP & SESSION
   ═══════════════════════════════════════════ */
.constraint-item { margin-bottom: 10px; }

.constraint-checkbox {
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: all var(--duration) var(--ease);
  cursor: pointer;
}
.constraint-checkbox:hover {
  border-color: var(--primary-light);
  background: var(--primary-50);
}
.constraint-checkbox.active {
  border-color: var(--primary);
  background: var(--primary-50);
}
.constraint-checkbox input[type="checkbox"] { margin-right: 8px; }

.constraint-label {
  font-weight: 500;
  color: var(--text);
  margin: 0;
}

.constraint-description {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 4px 0 0 24px;
}

/* Session Timer */
.session-timer {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 1.15rem;
  font-weight: 700;
}

#sessionTimer {
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(10px);
  letter-spacing: 0.05em;
}

/* Active Constraints Badge */
.constraint-badge {
  background: var(--primary);
  color: #fff;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  margin-right: 6px;
  margin-bottom: 6px;
  display: inline-block;
}

/* Session Info Cards */
.session-info-card {
  background: var(--surface);
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.session-info-card strong { color: var(--text); }

/* ═══════════════════════════════════════════
   VIDEO RECORDING
   ═══════════════════════════════════════════ */
.video-recording-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.camera-preview {
  width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  background: var(--text);
  object-fit: cover;
}

.recorded-video {
  width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  background: var(--text);
}

.recording-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--danger-light);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
}

.recording-pulse {
  animation: recording-pulse-anim 1s infinite;
}

@keyframes recording-pulse-anim {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.video-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.recorded-video-preview .recorded-video {
  border: 2px solid var(--success);
}

.session-video-replay {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.session-video-replay video {
  width: 100%;
  max-height: 400px;
  border-radius: var(--radius-sm);
  background: var(--text);
}

.video-file-name {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════
   ASSESSMENT
   ═══════════════════════════════════════════ */
.session-summary {
  background: var(--surface);
  padding: 1.25rem;
  border-radius: var(--radius);
  margin-top: 1rem;
  border: 1px solid var(--border);
}

.stat-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.stat-item i { margin-right: 8px; font-size: 1.1rem; }
.stat-item strong { margin-right: 8px; }

/* ─── Rating Buttons ─── */
.rating-container { margin-bottom: 1.5rem; }

.rating-scale {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
  width: 100%;
}

.rating-btn {
  width: 52px;
  height: 52px;
  border: 2px solid var(--border);
  background: var(--surface-raised);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  position: relative;
  box-shadow: var(--shadow-sm);
}

.rating-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Colour-coded ratings */
.rating-btn[data-rating="1"],
.rating-btn[data-rating="2"] {
  border-color: var(--danger);
  color: var(--danger);
}
.rating-btn[data-rating="1"]:hover,
.rating-btn[data-rating="2"]:hover {
  background: var(--danger-light);
}

.rating-btn[data-rating="3"] {
  border-color: var(--warning);
  color: #92400e;
}
.rating-btn[data-rating="3"]:hover {
  background: var(--warning-light);
}

.rating-btn[data-rating="4"],
.rating-btn[data-rating="5"] {
  border-color: var(--success);
  color: var(--success);
}
.rating-btn[data-rating="4"]:hover,
.rating-btn[data-rating="5"]:hover {
  background: var(--success-light);
}

.rating-btn.selected {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

.rating-btn.selected[data-rating="1"],
.rating-btn.selected[data-rating="2"] {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.rating-btn.selected[data-rating="3"] {
  background: var(--warning);
  border-color: var(--warning);
  color: #fff;
}

.rating-btn.selected[data-rating="4"],
.rating-btn.selected[data-rating="5"] {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.rating-anchors { display: none; }

/* ─── Technical Skills Sliders ─── */
.skill-slider-container {
  position: relative;
  margin: 20px 0;
  width: 100%;
}

.skill-slider {
  width: 100%;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right, #ef4444 0%, #f59e0b 25%, #eab308 50%, #22c55e 75%, #16a34a 100%);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  opacity: 0.85;
  transition: opacity var(--duration) var(--ease);
}

.skill-slider:hover { opacity: 1; }

.skill-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--duration) var(--ease);
}

.skill-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-lg);
}

.skill-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

.skill-value {
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  margin: 12px 0;
  padding: 6px;
  background: var(--primary-50);
  border-radius: var(--radius);
}

.skill-description {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 8px 0;
  padding: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  border-left: 3px solid var(--primary);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration) var(--ease);
}

.technical-skill-item {
  margin-bottom: 20px;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
}

.skill-name {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

/* ─── NASA-TLX Sliders ─── */
.nasa-tlx-item {
  margin-bottom: 20px;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
}

.tlx-dimension {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.tlx-slider-container {
  position: relative;
  margin: 20px 0;
  width: 100%;
}

.tlx-slider {
  width: 100%;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right, #16a34a 0%, #22c55e 20%, #eab308 50%, #f59e0b 80%, #ef4444 100%);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  opacity: 0.85;
  transition: opacity var(--duration) var(--ease);
}

.tlx-slider:hover { opacity: 1; }

.tlx-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--duration) var(--ease);
}

.tlx-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-lg);
}

.tlx-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

.tlx-description {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 8px 0;
  padding: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  border-left: 3px solid var(--primary);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration) var(--ease);
}

.tlx-anchors { display: none; }

/* Overall Rating */
#overallRating {
  justify-content: space-between;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

#overallRating .rating-btn {
  flex: 1;
  margin: 0 4px;
  width: auto;
  min-width: 54px;
}

.overall-rating-description {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 12px 0;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  border-left: 3px solid var(--primary);
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration) var(--ease);
}

/* Mobile Assessment */
@media (max-width: 768px) {
  .rating-btn {
    width: 48px;
    height: 48px;
    font-size: 0.95rem;
  }
  .rating-scale { gap: 6px; }
  .technical-skill-item,
  .nasa-tlx-item { padding: 12px; margin-bottom: 16px; }
  .tlx-slider,
  .skill-slider { height: 14px; }
  .tlx-slider::-webkit-slider-thumb,
  .skill-slider::-webkit-slider-thumb { width: 32px; height: 32px; }
  .tlx-slider::-moz-range-thumb,
  .skill-slider::-moz-range-thumb { width: 32px; height: 32px; }
  .tlx-value,
  .skill-value { font-size: 1.3rem; }
  #overallRating .rating-btn { min-width: 50px; margin: 0 3px; }
}

/* ═══════════════════════════════════════════
   SESSIONS HISTORY
   ═══════════════════════════════════════════ */
.sessions-stats-bar {
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration) var(--ease);
  border-radius: var(--radius) !important;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-100);
}

.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.session-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  transition: all var(--duration) var(--ease);
  cursor: pointer;
}

.session-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-100);
}

.session-card.expanded {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.session-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 0.5rem;
}

.session-date {
  font-weight: 600;
  color: var(--text);
}

.session-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.session-status.completed {
  background-color: var(--success-light);
  color: var(--success);
}

.session-status.incomplete {
  background-color: var(--warning-light);
  color: var(--warning);
}

.session-path {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}
.session-path i { margin: 0 0.2rem; font-size: 0.7rem; }

.session-metrics {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.session-metric {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.session-metric i { color: var(--primary); font-size: 0.85rem; }

.session-details {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: none;
}
.session-card.expanded .session-details { display: block; }

.session-detail-section { margin-bottom: 0.75rem; }

.session-detail-section h6 {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.session-constraints {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.session-assessment {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}

.assessment-item {
  background-color: var(--surface);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.assessment-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.assessment-value {
  font-weight: 700;
  color: var(--text);
}

.session-notes,
.session-reflection {
  background-color: var(--surface);
  padding: 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ─── Session Video Link ─── */
.session-video-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  font-size: 0.85rem;
  word-break: break-all;
  text-decoration: none;
  padding: 6px 10px;
  background: var(--primary-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary-100);
  transition: background 0.2s ease;
}

.session-video-link:hover {
  background: var(--primary-100);
  color: var(--primary-dark);
}

/* ─── Session Action Buttons ─── */
.session-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.session-actions .btn {
  font-size: 0.8rem;
  padding: 5px 14px;
  border-radius: var(--radius);
  font-weight: 600;
}

.test-controls {
  background-color: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ─── Constraint Badges (Session History) ─── */
.constraint-category-group {
  margin-bottom: 0.5rem;
}

.constraint-badge {
  display: inline-block;
  padding: 3px 10px;
  margin: 0.15rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  background-color: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.surgical-constraint-badge {
  background-color: var(--danger-light);
  color: var(--danger);
  border-color: rgba(220,38,38,0.2);
}

.circumstantial-constraint-badge {
  background-color: var(--warning-light);
  color: var(--warning);
  border-color: rgba(217,119,6,0.2);
}

.personnel-constraint-badge {
  background-color: var(--info-light);
  color: var(--info);
  border-color: rgba(8,145,178,0.2);
}

/* ═══════════════════════════════════════════
   BUTTON ALIGNMENT FIXES (iOS / cross-browser)
   ═══════════════════════════════════════════ */
.btn-group {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
}

.btn-group > .btn {
  flex: 1;
  min-height: 46px !important;
  line-height: 1.5 !important;
  padding: 10px 16px !important;
  margin: 0 !important;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-group > .btn-outline-primary,
.btn-group > .btn-outline-secondary {
  border-width: 1.5px;
}

@supports (-webkit-touch-callout: none) {
  .btn { -webkit-appearance: none; appearance: none; }
  .btn-group > .btn { min-height: 46px !important; height: 46px; }
}

.card-footer .btn-group > .btn { min-height: 42px !important; }
.modal-footer .btn { min-height: 42px; padding: 10px 20px; }

.navbar .btn,
.nav-link.btn {
  min-height: var(--touch-target-size);
  display: inline-flex;
  align-items: center;
}

.practice-controls .btn,
.assessment-controls .btn {
  min-height: 48px;
  padding: 12px 24px;
}

@media (max-width: 768px) {
  .btn { min-height: 46px !important; font-size: 0.9375rem; }
  .btn-group > .btn { min-height: 46px !important; padding: 12px 16px !important; }
  .btn-sm { min-height: 38px; padding: 8px 14px; }
  .btn-lg { min-height: 52px; padding: 14px 24px; }
}

.floating-btn,
.fab {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
  box-shadow: var(--shadow-lg);
}

form .btn[type="submit"],
form button[type="submit"] {
  min-height: 46px;
  width: 100%;
  margin-top: 0.5rem;
}

/* ═══════════════════════════════════════════
   LIVE SESSION HEADER - green override
   ═══════════════════════════════════════════ */
.card-header.bg-success {
  background: var(--success) !important;
  color: #fff;
}

.card-header.bg-success h3,
.card-header.bg-success .h6 {
  color: #fff;
}

.card-header.bg-info {
  background: var(--info) !important;
  color: #fff;
}

.card-header.bg-info h3,
.card-header.bg-info .h6 {
  color: #fff;
}

/* Sticky timer controls */
#liveSessionPage .card-body > .text-center:first-child {
  background: var(--surface-raised);
  border-bottom: 2px solid var(--success);
}

/* ═══════════════════════════════════════════
   ANALYTICS CHART
   ═══════════════════════════════════════════ */
#chartContainer {
  border-radius: var(--radius);
}

/* Monthly comparison toggle */
.form-check.form-switch .form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

/* ═══════════════════════════════════════════
   BADGE OVERRIDES (Bootstrap)
   ═══════════════════════════════════════════ */
.badge {
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* ═══════════════════════════════════════════
   ALERT OVERRIDES
   ═══════════════════════════════════════════ */
.alert {
  border-radius: var(--radius);
  border: none;
  font-size: 0.9375rem;
}

/* ═══════════════════════════════════════════
   TABLE OVERRIDES (for admin & sessions)
   ═══════════════════════════════════════════ */
.table {
  font-size: 0.875rem;
}
.table th {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom-width: 2px;
}

/* ═══════════════════════════════════════════
   SCROLLBAR (Webkit)
   ═══════════════════════════════════════════ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Pulse dot (live session indicator) ─── */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* ═══════════════════════════════════════════
   LANDING PAGE
   ═══════════════════════════════════════════ */

/* Full-width override: landing page breaks out of container */
#login-section {
  margin: 0;
  padding: 0;
}

/* ─── Landing Navbar (sticky) ─── */
.landing-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  padding: calc(14px + env(safe-area-inset-top)) 0 14px;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  transition: background 0.3s ease, box-shadow 0.3s ease;
  /* iOS safe area horizontal */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.landing-nav.scrolled {
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.landing-nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 800;
  font-size: 1.125rem;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.landing-nav-brand:hover {
  color: #fff;
  text-decoration: none;
}

.landing-nav-brand i {
  color: #60a5fa;
  font-size: 1.25rem;
}

.landing-nav-link {
  color: rgba(255,255,255,0.85);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.landing-nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
  text-decoration: none;
}

.landing-nav-btn {
  display: inline-flex;
  align-items: center;
  color: #0f172a;
  font-weight: 700;
  font-size: 0.875rem;
  text-decoration: none;
  padding: 8px 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  transition: all 0.25s ease;
  box-shadow: 0 2px 8px rgba(96,165,250,0.3);
}

.landing-nav-btn:hover {
  color: #0f172a;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(96,165,250,0.45);
}

/* ─── Hero ─── */
.landing-hero {
  position: relative;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 40%, #1d4ed8 100%);
  overflow: hidden;
  min-height: 85vh;
  min-height: 85dvh; /* Dynamic viewport height for iOS Safari */
  display: flex;
  align-items: center;
  padding-top: calc(64px + env(safe-area-inset-top));
  padding-bottom: env(safe-area-inset-bottom);
}

.landing-hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 70% 20%, rgba(99,102,241,0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 20% 80%, rgba(37,99,235,0.2) 0%, transparent 50%);
  pointer-events: none;
}

/* Subtle grid pattern */
.landing-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
}

.min-vh-75 {
  min-height: 75vh;
  min-height: 75dvh;
}

.landing-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.9);
  backdrop-filter: blur(8px);
}

.landing-hero-title {
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 1.25rem;
  color: #fff;
}

.landing-gradient-text {
  background: linear-gradient(135deg, #60a5fa, #a78bfa, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-hero-subtitle {
  font-size: 1.0625rem;
  line-height: 1.7;
  color: rgba(255,255,255,0.8);
  max-width: 540px;
}

.landing-cta-btn {
  padding: 14px 32px !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  transition: all 0.25s var(--ease);
  color: var(--primary-dark) !important;
  border: none !important;
}

.landing-cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.landing-cta-btn-outline {
  padding: 14px 32px !important;
  font-size: 1rem !important;
  font-weight: 600 !important;
  border-radius: var(--radius-lg) !important;
  border: 1.5px solid rgba(255,255,255,0.4) !important;
  color: #fff !important;
  background: rgba(255,255,255,0.08) !important;
  backdrop-filter: blur(4px);
}

.landing-cta-btn-outline:hover {
  background: rgba(255,255,255,0.15) !important;
  border-color: rgba(255,255,255,0.6) !important;
  transform: translateY(-1px);
}

.landing-trust {
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.55);
  font-weight: 500;
}

.landing-trust i {
  color: rgba(255,255,255,0.4);
}

/* ─── Hero Visual (mock dashboard card) ─── */
.landing-hero-visual {
  perspective: 1000px;
}

.landing-mock-card {
  width: 360px;
  background: var(--surface-raised);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 60px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.1);
  overflow: hidden;
  transform: rotateY(-6deg) rotateX(4deg);
  transition: transform 0.5s var(--ease);
}

.landing-mock-card:hover {
  transform: rotateY(-2deg) rotateX(1deg);
}

.landing-mock-header {
  background: var(--surface);
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.landing-mock-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.landing-mock-body {
  padding: 20px;
}

.landing-mock-stat {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.landing-mock-stat:last-of-type {
  border-bottom: none;
  margin-bottom: 16px;
}

.landing-mock-stat i {
  font-size: 1.5rem;
  width: 36px;
  text-align: center;
}

.landing-mock-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.landing-mock-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}

.landing-mock-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  margin-bottom: 10px;
  overflow: hidden;
}

.landing-mock-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--primary);
  animation: barGrow 1.5s var(--ease) forwards;
  transform-origin: left;
}

@keyframes barGrow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ─── Features ─── */
.landing-features {
  background: var(--surface-raised);
  border-top: 1px solid var(--border);
}

.landing-section-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.landing-section-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto;
}

.landing-feature-card {
  padding: 2rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  transition: all 0.25s var(--ease);
  height: 100%;
}

.landing-feature-card:hover {
  border-color: var(--primary-100);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.landing-feature-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.landing-feature-card h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.landing-feature-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0;
}

/* ─── How It Works ─── */
.landing-how-it-works {
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.landing-step-card {
  text-align: center;
  padding: 2.5rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  transition: all 0.25s var(--ease);
  height: 100%;
  position: relative;
}

.landing-step-card:hover {
  border-color: var(--primary-100);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.landing-step-number {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.landing-step-card h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.landing-step-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0;
}

/* ─── Stats / Social Proof ─── */
.landing-stats {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  border-top: 1px solid rgba(255,255,255,0.1);
}

.landing-stat-item {
  padding: 1.5rem 1rem;
}

.landing-stat-number {
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-stat-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Auth Section (embedded in landing) ─── */
.landing-auth-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.landing-auth-card {
  border: none !important;
  box-shadow: var(--shadow-lg) !important;
  border-radius: var(--radius-xl) !important;
}

.landing-auth-card .card-body {
  padding: 2rem !important;
}

/* ─── Landing Footer ─── */
.landing-footer {
  background: var(--surface-raised);
  border-top: 1px solid var(--border);
}

.landing-footer strong {
  color: var(--text);
  font-size: 0.9375rem;
}

/* ─── Landing Mobile Responsive ─── */
@media (max-width: 768px) {
  .landing-hero {
    min-height: auto;
    padding: calc(80px + env(safe-area-inset-top)) 0 2rem;
  }

  .min-vh-75 { min-height: auto; }

  .landing-hero-title {
    font-size: 1.75rem;
  }

  .landing-hero-subtitle {
    font-size: 0.9375rem;
  }

  .landing-cta-btn,
  .landing-cta-btn-outline {
    padding: 12px 24px !important;
    font-size: 0.9375rem !important;
    width: 100%;
    text-align: center;
  }

  .landing-section-title {
    font-size: 1.4rem;
  }

  .landing-feature-card {
    padding: 1.5rem 1.25rem;
  }

  .landing-stat-number {
    font-size: 2rem;
  }

  .landing-mock-card {
    display: none;
  }

  .landing-nav-link {
    display: none;
  }

  .landing-nav-btn {
    min-height: var(--touch-target-size);
    font-size: 0.875rem;
    padding: 10px 16px;
  }

  /* Better spacing for mobile feature cards */
  .landing-feature-card h3 {
    font-size: 1rem;
  }

  .landing-feature-card p {
    font-size: 0.8125rem;
  }

  .landing-step-card {
    padding: 1.5rem 1rem;
  }

  /* Auth form mobile improvements */
  .landing-auth-card .card-body {
    padding: 1.25rem !important;
  }
}

/* Landing dark mode */
@media (prefers-color-scheme: dark) {
  .landing-features { background: var(--surface-raised); }
  .landing-how-it-works { background: var(--surface); }
  .landing-auth-section { background: var(--surface); }
  .landing-footer { background: var(--surface-raised); }
  .landing-feature-card { background: var(--surface-raised); }
  .landing-step-card { background: var(--surface-raised); }
  .landing-mock-card { background: var(--surface-raised); }
  .landing-mock-header { background: var(--surface); }
}

/* ═══════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════ */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info)    !important; }
