/* style.css - Astory Education Design System */
/* Modern Purple/Indigo Theme with Rich & Feature-Dense Design */

/* Stage 82: self-hosted fonts (lib/fonts, SIL OFL 1.1). Paths are relative to this file. */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('../lib/fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('../lib/fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('../lib/fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('../lib/fonts/inter-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 800; font-display: swap; src: url('../lib/fonts/inter-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 500; font-display: swap; src: url('../lib/fonts/fraunces-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 600; font-display: swap; src: url('../lib/fonts/fraunces-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 700; font-display: swap; src: url('../lib/fonts/fraunces-latin-700-normal.woff2') format('woff2'); }

/* =============================================================================
   CSS VARIABLES - Design Tokens
   ============================================================================= */
:root {
  /* Primary Purple/Indigo Palette */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #a5b4fc;
  --primary-lighter: #e0e7ff;
  --primary-dark: #3730a3;
  --primary-darker: #312e81;

  /* Secondary Purple */
  --secondary: #8b5cf6;
  --secondary-hover: #7c3aed;
  --secondary-light: #c4b5fd;
  --secondary-lighter: #ede9fe;

  /* Accent Colors */
  --accent: #a855f7;
  --accent-light: #d8b4fe;

  /* Course Map buttons (Stage 73): one colour everywhere */
  --course-map: #ea580c;
  --course-map-dark: #c2410c;

  /* Gradients */
  --gradient-hero: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --gradient-card: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --gradient-accent: linear-gradient(90deg, #8b5cf6, #6366f1);
  --gradient-subtle: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  --gradient-gold: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);

  /* Backgrounds */
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-muted: #e2e8f0;
  --bg-dark: #1e293b;

  /* Text Colors */
  --text-main: #1e293b;
  --text-secondary: #475569;
  --text-muted: #5b6b82; /* Stage 82 Phase D: was #64748b (4.3:1 on grey panels); now 4.75:1 or better on every light background */
  --text-light: #94a3b8;
  --text-inverse: #ffffff;

  /* Semantic Colors */
  --success: #10b981;
  --success-light: #d1fae5;
  --success-dark: #065f46;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --warning-dark: #92400e;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --danger-dark: #991b1b;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --info-dark: #1e40af;

  /* Borders */
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --border-focus: var(--primary);

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
  --shadow-glow-lg: 0 0 40px rgba(99, 102, 241, 0.4);

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-bounce: 300ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Font Sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;

  /* Stage 82: typography */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;

  /* Stage 82: form field border (stronger than --border so fields stay visible) */
  --border-strong: #cbd5e1;

  /* Stage 82: aliases for variable names that older pages use */
  --text: var(--text-main);
  --text-primary: var(--text-main);
  --muted: var(--text-muted);
  --surface: var(--bg-card);
  --surface-2: var(--bg-subtle);
  --line: var(--border);
  --accent-dark: var(--primary-dark);
  --warn-bg: var(--warning-light);
  --warn-text: var(--warning-dark);
  --warn-line: #fcd34d;
  --space-7: 28px;
  --primary-lightest: #eef2ff;
}

/* =============================================================================
   BASE STYLES
   ============================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  line-height: 1.6;
  font-size: var(--text-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.home-page {
  background-color: var(--bg-card);
}

/* =============================================================================
   LAYOUT
   ============================================================================= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-10) var(--space-5);
}

.container-sm {
  max-width: 600px;
}

.container-md {
  max-width: 800px;
}

.container-lg {
  max-width: 1000px;
}

/* Admin pages (sys/header.php): 90% of the screen on wide monitors, never narrower than the normal 1200px */
.container.container-admin {
  max-width: max(1200px, 90%);
}

/* Admin pages that open their own .container inside the header's one */
.container-admin .container {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

/* =============================================================================
   NAVIGATION
   ============================================================================= */
.navbar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: var(--space-4) 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: box-shadow var(--transition-base), background var(--transition-base);
}

.navbar.scrolled {
  box-shadow: var(--shadow-md);
  background: rgba(255, 255, 255, 0.98);
}

.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  font-weight: 800;
  font-size: var(--text-xl);
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: opacity var(--transition-base);
}

.brand:hover {
  opacity: 0.85;
}

.brand-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  position: relative;
}

.nav-links a:hover {
  color: var(--primary);
  background: var(--primary-lighter);
}

.nav-links a.active {
  color: var(--primary);
  background: var(--primary-lighter);
}

.nav-links .nav-admin {
  color: var(--secondary);
}

.nav-links .nav-admin:hover {
  color: var(--secondary-hover);
  background: var(--secondary-lighter);
}

.nav-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 var(--space-2);
}

/* =============================================================================
   TYPOGRAPHY
   ============================================================================= */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-4);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-main);
}

h1 {
  font-size: var(--text-3xl);
  font-weight: 800;
  margin-bottom: var(--space-6);
}

h2 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-5);
}

h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-4);
}

h4 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-3);
}

p {
  margin: 0 0 var(--space-4);
}

.small {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

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

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

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

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

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

.font-bold {
  font-weight: 700;
}

.font-semibold {
  font-weight: 600;
}

/* =============================================================================
   CARDS
   ============================================================================= */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

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

.card-highlight {
  background: var(--gradient-card);
  color: var(--text-inverse);
  border: none;
}

.card-highlight h1,
.card-highlight h2,
.card-highlight h3,
.card-highlight h4 {
  color: var(--text-inverse);
}

.card-feature {
  text-align: center;
  padding: var(--space-8);
}

.card-feature .feature-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-5);
  background: var(--primary-lighter);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: var(--text-2xl);
}

.card-feature h3 {
  margin-bottom: var(--space-3);
}

.card-feature p {
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* =============================================================================
   BUTTONS
   ============================================================================= */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: none;
  border-radius: var(--radius-lg);
  background: var(--gradient-card);
  color: var(--text-inverse);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  filter: brightness(1.05);
}

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

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
  border-radius: var(--radius-xl);
}

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

.btn-secondary {
  background: var(--bg-card);
  border: 2px solid var(--border);
  color: var(--text-main);
  box-shadow: none;
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-lighter);
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--primary-lighter);
  transform: translateY(-2px);
}

.btn-danger {
  background: #dc2626; /* Stage 82 Phase D (owner approved): was var(--danger) #ef4444, white text 3.8:1; now 4.8:1 */
}

.btn-danger:hover {
  background: var(--danger-dark);
}

.btn-success {
  background: #047857; /* Stage 82 Phase D (owner approved): was var(--success) #10b981, white text 2.5:1; now 5.5:1 */
}

.btn-success:hover {
  background: var(--success-dark);
  color: #fff; /* Stage 82 (owner): a:hover turned green link buttons' text indigo on hover */
}

/* Stage 82 (owner): dashboard "Course Home" turns slightly lighter green on hover (MemberHome only) */
.my-course-card__actions .btn-success:hover {
  background: #059669;
}

.btn-course-map {
  background: linear-gradient(135deg, var(--course-map) 0%, var(--course-map-dark) 100%);
  color: #fff;
  border: 0;
}

.btn-course-map:hover {
  color: #fff;
}

.btn-course-map:focus-visible {
  outline: 3px solid rgba(234, 88, 12, 0.45);
  outline-offset: 2px;
}

.btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* =============================================================================
   FORMS
   ============================================================================= */
label,
.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--text-main);
  font-size: var(--text-sm);
}

input, select, textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--text-base);
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-main);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) {
  border-color: var(--text-light);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

input:disabled, select:disabled, textarea:disabled {
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
}

input::placeholder, textarea::placeholder {
  color: var(--text-light);
}

input[type="checkbox"], input[type="radio"] {
  width: auto;
  margin-right: var(--space-2);
  margin-bottom: 0;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: calc(-1 * var(--space-3));
  margin-bottom: var(--space-4);
}

/* =============================================================================
   TABLES
   ============================================================================= */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-subtle);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

/* Column headers: small caps style. Row headers (th inside tbody) keep the normal style. */
thead th {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td {
  padding: 14px var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: var(--bg-subtle);
}

/* =============================================================================
   BADGES & TAGS
   ============================================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-primary {
  background: var(--primary-lighter);
  color: var(--primary-dark);
}

.badge-secondary {
  background: var(--secondary-lighter);
  color: var(--secondary-hover);
}

.badge-success {
  background: var(--success-light);
  color: var(--success-dark);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning-dark);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger-dark);
}

.badge-info {
  background: var(--info-light);
  color: var(--info-dark);
}

.tag {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--primary-lighter);
  color: var(--primary);
}

/* Level Badge */
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--gradient-accent);
  color: var(--text-inverse);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--text-sm);
  box-shadow: var(--shadow-sm);
}

/* =============================================================================
   PROGRESS BARS
   ============================================================================= */
.progress-bar {
  height: 8px;
  background: var(--bg-muted);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-accent);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress-lg {
  height: 12px;
}

/* =============================================================================
   ALERTS & MESSAGES
   ============================================================================= */
.msg, .notice, div.error {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  line-height: 1.55;
  border: 1px solid;
  border-left-width: 4px;
}

.msg {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  animation: slideInFromTop 0.3s ease;
}

/* .notice and div.error: older class names (verify / change pages, device_conflict.php) */
.msg-info, .msg, .notice {
  background: #eff6ff;
  color: var(--info-dark);
  border-color: #bfdbfe;
  border-left-color: var(--info);
}

.msg-success {
  background: #ecfdf5;
  color: var(--success-dark);
  border-color: #a7f3d0;
  border-left-color: var(--success);
}

.msg-warning {
  background: #fffbeb;
  color: var(--warning-dark);
  border-color: #fde68a;
  border-left-color: var(--warning);
}

.msg-error, .msg.err, div.error {
  background: #fef2f2;
  color: var(--danger-dark);
  border-color: #fecaca;
  border-left-color: var(--danger);
}

/* Stage 84: `.msg { display:flex }` overrode the [hidden] attribute, so empty, hidden
   messages (e.g. the fill-in-the-blank sync status on Question.php) showed as a red band. */
.msg[hidden], .notice[hidden], div.error[hidden] {
  display: none !important;
}

/* =============================================================================
   HERO SECTION
   ============================================================================= */
.hero {
  background: var(--gradient-hero);
  color: var(--text-inverse);
  padding: var(--space-16) var(--space-5);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
}

.hero h1 {
  font-size: var(--text-5xl);
  font-weight: 800;
  margin-bottom: var(--space-4);
  line-height: 1.1;
  color: var(--text-inverse);
}

.hero-subtitle {
  font-size: var(--text-xl);
  opacity: 0.9;
  margin-bottom: var(--space-8);
  line-height: 1.6;
}

.hero-cta {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  flex-wrap: wrap;
}

.hero-btn {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
  border-radius: var(--radius-xl);
  font-weight: 700;
  transition: all var(--transition-base);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.hero-btn-primary {
  background: var(--text-inverse);
  color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.hero-btn-primary:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-xl);
}

.hero-btn-secondary {
  background: transparent;
  border: 2px solid var(--text-inverse);
  color: var(--text-inverse);
}

.hero-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.05);
}

/* Hero Decorations */
.hero-decoration {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.hero-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.hero-circle-1 {
  width: 400px;
  height: 400px;
  top: -100px;
  right: -100px;
}

.hero-circle-2 {
  width: 300px;
  height: 300px;
  bottom: -50px;
  left: -50px;
}

/* =============================================================================
   STATS SECTION
   ============================================================================= */
.stats-section {
  background: var(--bg-card);
  padding: var(--space-12) var(--space-5);
  margin: calc(-1 * var(--space-10)) auto 0;
  max-width: 1000px;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 10;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-8);
  text-align: center;
}

.stat-item {
  padding: var(--space-4);
}

.stat-number {
  font-size: var(--text-4xl);
  font-weight: 800;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: var(--space-2);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 500;
}

/* =============================================================================
   SECTION STYLES
   ============================================================================= */
.section {
  padding: var(--space-16) var(--space-5);
}

.section-header {
  text-align: center;
  max-width: 600px;
  margin: 0 auto var(--space-12);
}

.section-header h2 {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-4);
}

.section-header p {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  margin: 0;
}

.section-alt {
  background: var(--bg-subtle);
}

/* Features Grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-6);
  max-width: 1200px;
  margin: 0 auto;
}

/* Courses Grid */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-6);
  max-width: 1200px;
  margin: 0 auto;
}

.course-card {
  position: relative;
}

.course-badge {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
}

.course-card h3 {
  margin-bottom: var(--space-2);
  font-size: var(--text-xl);
}

.course-tutor {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.course-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) 0;
  border-top: 1px solid var(--border);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.course-price {
  font-weight: 700;
  color: var(--primary);
}

.courses-cta {
  text-align: center;
  margin-top: var(--space-10);
}

/* Team Grid */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-8);
  max-width: 900px;
  margin: 0 auto;
}

.team-card {
  text-align: center;
  padding: var(--space-8);
}

.team-avatar {
  width: 120px;
  height: 120px;
  margin: 0 auto var(--space-5);
  border-radius: 50%;
  overflow: hidden;
  background: var(--gradient-subtle);
  border: 4px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.avatar-placeholder {
  font-size: var(--text-4xl);
  font-weight: 800;
  color: var(--text-light);
}

.team-card h3 {
  margin-bottom: var(--space-1);
}

.team-role {
  color: var(--primary);
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.team-badges {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.team-bio {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin: 0;
}

/* CTA Section */
.cta-section {
  background: var(--gradient-hero);
  color: var(--text-inverse);
  padding: var(--space-16) var(--space-5);
  text-align: center;
}

.cta-content {
  max-width: 600px;
  margin: 0 auto;
}

.cta-content h2 {
  color: var(--text-inverse);
  font-size: var(--text-3xl);
  margin-bottom: var(--space-4);
}

.cta-content p {
  opacity: 0.9;
  font-size: var(--text-lg);
  margin-bottom: var(--space-8);
}

/* =============================================================================
   FOOTER
   ============================================================================= */
.footer {
  background: var(--bg-dark);
  color: var(--text-inverse);
  padding: var(--space-12) var(--space-5) var(--space-6);
  border-top: 4px solid transparent;
  border-image: var(--gradient-hero) 1;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-8);
  margin-bottom: var(--space-10);
}

.footer-brand {
  max-width: 300px;
}

.footer-brand .brand {
  margin-bottom: var(--space-4);
  font-size: var(--text-xl);
  background: none;
  color: var(--text-inverse);
  -webkit-text-fill-color: var(--text-inverse);
}

.footer-brand p {
  color: var(--text-light);
  font-size: var(--text-sm);
  margin: 0;
}

.footer-links h4,
.footer-contact h4,
.footer-heading {
  color: var(--text-inverse);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-4);
}

.footer-links ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: var(--space-2);
}

.footer-links a {
  color: var(--text-light);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--text-inverse);
}

.footer-contact p {
  color: var(--text-light);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: var(--space-6);
  text-align: center;
}

.footer-bottom p {
  color: var(--text-light);
  font-size: var(--text-sm);
  margin: 0;
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */
.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

.w-full { width: 100%; }
.max-w-sm { max-width: 400px; }
.max-w-md { max-width: 600px; }
.max-w-lg { max-width: 800px; }

.mx-auto { margin-left: auto; margin-right: auto; }

.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.bg-subtle { background: var(--bg-subtle); }
.bg-muted { background: var(--bg-muted); }

.border { border: 1px solid var(--border); }
.border-t { border-top: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }

/* =============================================================================
   ANIMATIONS
   ============================================================================= */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

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

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

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

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

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Animation Classes */
.animate-fadeIn { animation: fadeIn 0.5s ease forwards; }
.animate-fadeInUp { animation: fadeInUp 0.5s ease forwards; }
.animate-fadeInScale { animation: fadeInScale 0.3s ease forwards; }
.animate-slideInLeft { animation: slideInLeft 0.4s ease forwards; }
.animate-pulse { animation: pulse 2s infinite; }
.animate-bounce { animation: bounce 2s infinite; }

/* Staggered Animation Delays */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }

/* Initial state for animated elements */
[class*="animate-fadeIn"],
[class*="animate-slideIn"] {
  opacity: 0;
}

/* Hover Effects */
.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

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

.hover-scale {
  transition: transform var(--transition-base);
}

.hover-scale:hover {
  transform: scale(1.02);
}

.hover-glow:hover {
  box-shadow: var(--shadow-glow);
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 768px) {
  :root {
    --text-5xl: 2.5rem;
    --text-4xl: 2rem;
    --text-3xl: 1.5rem;
  }

  .hero {
    padding: var(--space-12) var(--space-4);
  }

  .hero h1 {
    font-size: var(--text-4xl);
  }

  .hero-subtitle {
    font-size: var(--text-base);
  }

  .hero-cta {
    flex-direction: column;
    align-items: center;
  }

  .hero-btn {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }

  .stats-section {
    margin-top: calc(-1 * var(--space-6));
    padding: var(--space-8) var(--space-4);
    border-radius: var(--radius-xl);
  }

  .stat-number {
    font-size: var(--text-3xl);
  }

  .section {
    padding: var(--space-10) var(--space-4);
  }

  .section-header {
    margin-bottom: var(--space-8);
  }

  .nav-links {
    gap: 0;
  }

  .nav-links a {
    padding: var(--space-2);
    font-size: var(--text-xs);
  }

  .container {
    padding: var(--space-6) var(--space-4);
  }

  .card {
    padding: var(--space-5);
  }

  .footer-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .footer-brand {
    max-width: none;
  }
}

/* =============================================================================
   SPECIFIC PAGE STYLES
   ============================================================================= */

/* Dashboard Welcome Card */
.welcome-card {
  background: var(--gradient-hero);
  color: var(--text-inverse);
  border: none;
  position: relative;
  overflow: hidden;
}

.welcome-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
}

.welcome-card h1,
.welcome-card h2,
.welcome-card h3 {
  color: var(--text-inverse);
}

/* Wallet Card */
.wallet-card {
  background: var(--bg-card);
  border: 2px solid var(--primary-light);
}

.wallet-balance {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--primary);
}

.wallet-label {
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Class Cards in Grid */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-6);
}

.class-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--transition-base);
}

.class-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.class-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-4);
}

.class-card h3 {
  margin: 0;
  font-size: var(--text-lg);
}

.class-card-tutor {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.class-card-meta {
  display: flex;
  gap: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.class-card-fee {
  font-weight: 700;
  color: var(--primary);
}

/* Card buttons: two columns; .is-wide takes a full row (Details when enrolled) */
.class-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.class-card-actions > * {
  min-width: 0;
}

.class-card-actions .is-wide {
  grid-column: 1 / -1;
}

.class-card-actions .btn {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.class-card.is-hidden-course {
  opacity: 0.65;
}

/* Stage 82 Phase C: .page-crumbs and .topic-nav were replaced by the shared .crumbs and .pager-nav */

/* Capacity Bar */
.capacity-bar {
  height: 6px;
  background: var(--bg-muted);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: var(--space-3) 0;
}

.capacity-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.capacity-fill.low { background: var(--success); }
.capacity-fill.medium { background: var(--warning); }
.capacity-fill.high { background: var(--danger); }

/* Login/Register Card */
.auth-card {
  max-width: 440px;
  margin: var(--space-10) auto;
  text-align: center;
}

.auth-card .card {
  padding: var(--space-10) var(--space-8);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-6) 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

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

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.page-header h1 {
  margin: 0;
}

/* Admin Styles */
.admin-badge {
  background: var(--secondary-lighter);
  color: var(--secondary);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
}

/* Search/Filter Form */
.filter-card {
  background: var(--bg-subtle);
  border: none;
  padding: var(--space-5);
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
  align-items: end;
}

.filter-form input,
.filter-form select {
  margin-bottom: 0;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
  margin-top: var(--space-5);
}

.pagination-info {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

/* Resource Sections */
.resource-section {
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.resource-section h3 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  margin-bottom: var(--space-3);
  color: var(--text-secondary);
}

.resource-content {
  color: var(--text-main);
  line-height: 1.7;
}

.resource-content a {
  color: var(--primary);
  text-decoration: none;
}

.resource-content a:hover {
  text-decoration: underline;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
  color: var(--text-muted);
}

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

.empty-state h3 {
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state p {
  margin-bottom: var(--space-6);
}

/* =============================================================================
   MOBILE HAMBURGER MENU
   ============================================================================= */
.nav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 0;
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.nav-hamburger:hover {
  border-color: var(--primary);
  background: var(--primary-lighter);
}

.nav-hamburger .bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: all var(--transition-base);
  position: relative;
}

.nav-hamburger .bar::before,
.nav-hamburger .bar::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: all var(--transition-base);
}

.nav-hamburger .bar::before { top: -6px; }
.nav-hamburger .bar::after  { top: 6px; }

.nav-hamburger.open .bar { background: transparent; }
.nav-hamburger.open .bar::before { transform: rotate(45deg); top: 0; }
.nav-hamburger.open .bar::after  { transform: rotate(-45deg); top: 0; }

@media (max-width: 768px) {
  .nav-hamburger { display: flex; }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-3) var(--space-4);
    gap: var(--space-1);
  }

  .nav-links.open { display: flex; }

  .nav-links a {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    border-radius: var(--radius-md);
  }

  .nav-divider {
    width: 100%;
    height: 1px;
    margin: var(--space-2) 0;
  }
}

/* =============================================================================
   LOGOUT HOVER DANGER
   ============================================================================= */
.nav-links a.nav-logout:hover {
  color: var(--danger);
  background: var(--danger-light);
}

/* =============================================================================
   ACCOUNT DROPDOWN + UNREAD MESSAGES BADGE (top bar)
   ============================================================================= */
.nav-user {
  position: relative;
}

.nav-user-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-base);
}

.nav-user-toggle:hover,
.nav-user.open .nav-user-toggle {
  color: var(--primary);
  background: var(--primary-lighter);
}

.nav-user-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.nav-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary-lighter);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.nav-user-caret {
  width: 14px;
  height: 14px;
  transition: transform var(--transition-base);
}

.nav-user.open .nav-user-caret {
  transform: rotate(180deg);
}

.nav-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.nav-unread-badge[hidden] {
  display: none;
}

.nav-user-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: 1001;
}

.nav-user.open .nav-user-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-links .nav-user-menu a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  white-space: nowrap;
}

.nav-user-menu a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-user-menu a .nav-unread-badge {
  margin-left: auto;
}

@media (max-width: 768px) {
  .nav-user-toggle {
    width: 100%;
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-base);
  }

  .nav-user-caret {
    margin-left: auto;
  }

  .nav-user-menu {
    position: static;
    min-width: 0;
    border: 0;
    box-shadow: none;
    padding: 0 0 0 var(--space-4);
    background: transparent;
  }
}

/* =============================================================================
   PROMO BALANCE TOOLTIP
   ============================================================================= */
.promo-tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.promo-balance-help {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid #16a34a;
  background: #f0fdf4;
  color: #16a34a;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  font-size: var(--text-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.promo-tooltip-wrap .promo-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dark);
  color: var(--text-inverse);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  white-space: nowrap;
  z-index: 200;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

.promo-tooltip-wrap .promo-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--bg-dark);
}

.promo-tooltip-wrap.show .promo-tooltip { display: block; }
.promo-tooltip-wrap:hover .promo-tooltip { display: block; }

/* =============================================================================
   JOIN CONFIRMATION MODAL
   ============================================================================= */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9000;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  animation: fadeIn 0.15s ease;
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-2xl);
  animation: fadeInScale 0.2s ease;
}

.modal-box h3 {
  margin-bottom: var(--space-3);
  font-size: var(--text-xl);
}

.modal-box p {
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* =============================================================================
   SUBJECT FILTER SCROLL (mobile)
   ============================================================================= */
.filter-bar-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-bar-scroll::-webkit-scrollbar { display: none; }

.filter-bar-scroll > div {
  min-width: max-content;
}

/* =============================================================================
   SUBJECT BADGE (course cards)
   ============================================================================= */
.subject-tag {
  display: inline-block;
  background: var(--primary-lighter);
  color: var(--primary-dark);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  margin-top: var(--space-1);
}

/* =============================================================================
   COURSE SEARCH
   ============================================================================= */
.course-search-wrap {
  position: relative;
  margin-bottom: var(--space-4);
}

.course-search-wrap svg {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
}

.course-search-input {
  padding-left: calc(var(--space-4) + 24px + var(--space-2));
  margin-bottom: 0;
}

/* =============================================================================
   BREADCRUMB
   ============================================================================= */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumb a:hover { color: var(--primary); }

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

/* =============================================================================
   EXPIRED COURSES SECTION
   ============================================================================= */
.expired-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: var(--space-6) 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

/* =============================================================================
   MEMBER INBOX (MyInbox.php, Admin/AdminInboxes.php)
   ============================================================================= */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.inbox-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.inbox-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.inbox-item + .inbox-item {
  border-top: 1px solid var(--border);
}

.inbox-item summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  list-style: none;
}

.inbox-item summary::-webkit-details-marker {
  display: none;
}

.inbox-item summary:hover {
  background: var(--primary-lighter);
}

.inbox-item[open] summary {
  background: var(--bg-subtle);
}

.inbox-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: transparent;
  flex-shrink: 0;
}

.inbox-item.is-unread .inbox-dot {
  background: var(--danger);
}

.inbox-title {
  flex: 1;
  min-width: 0;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-item.is-unread .inbox-title {
  font-weight: 700;
  color: var(--text-main);
}

.inbox-item[open] .inbox-title {
  white-space: normal;
}

.inbox-time {
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

.inbox-body {
  padding: var(--space-3) var(--space-4) var(--space-4) calc(var(--space-4) + 8px + var(--space-3));
  color: var(--text-secondary);
  line-height: 1.6;
}

.inbox-body p {
  margin: 0 0 var(--space-3) 0;
  overflow-wrap: anywhere;
}

@media (max-width: 768px) {
  .inbox-item summary {
    flex-wrap: wrap;
  }

  .inbox-title {
    flex-basis: 100%;
    order: 3;
    white-space: normal;
  }

  .inbox-body {
    padding-left: var(--space-4);
  }
}

/* =============================================================================
   STAGE 82 - FOUNDATION (Phase A)
   Shared components for the UI refresh. Button colours, hero/welcome cards and
   the wallet are deliberately unchanged (see STAGE82_NOTES.md).
   ============================================================================= */

/* ---- Typography: Fraunces display headings over Inter ---------------------- */
h1, h2 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.num {
  font-variant-numeric: tabular-nums;
}

.display-num {
  font-family: var(--font-display);
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
}

/* Buttons did not inherit the page font (browsers default <button> to the system font),
   so <button class="btn"> looked different from <a class="btn">. Typeface only; colours unchanged. */
button {
  font-family: inherit;
}

/* Labels placed inside h1/h2 keep the UI font instead of the Fraunces heading font. */
.chip, .badge, .tag, .level-badge, .admin-badge, .nav-unread-badge {
  font-family: var(--font-ui);
}

/* ---- Classes that older pages used but were never defined ----------------- */
.text-secondary {
  color: var(--text-secondary);
}

/* .btn-primary is the same look as .btn (used with it, e.g. device_conflict.php) */
.btn.btn-primary {
  background: var(--gradient-card);
  color: var(--text-inverse);
}

/* ---- Focus, skip link ----------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; /* fields use their own focus ring (border + glow) */
}

#main:focus {
  outline: none;
}

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -100px;
  z-index: 2000;
  background: var(--bg-dark);
  color: var(--text-inverse);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-2);
}

/* ---- Alerts: extras ------------------------------------------------------- */
.msg > svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.msg .btn {
  margin-left: auto;
  flex-shrink: 0;
}

.msg a:not(.btn) {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.msg-title {
  font-weight: 700;
}

/* ---- Forms ---------------------------------------------------------------- */
.form-field {
  margin-bottom: var(--space-5);
}

.form-field > label {
  margin-bottom: 6px;
}

.form-field input:not([type="checkbox"]):not([type="radio"]),
.form-field select,
.form-field textarea {
  margin-bottom: 0;
}

.form-field .hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 6px;
}

.form-field .error-text {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--danger-dark);
  margin-top: 6px;
}

.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea {
  border-color: var(--danger);
}

.form-field.has-error input:focus,
.form-field.has-error select:focus,
.form-field.has-error textarea:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}

.input-prefix {
  position: relative;
}

.input-prefix > .prefix {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-weight: 600;
  pointer-events: none;
}

.input-prefix > input {
  padding-left: 2.75em;
  margin-bottom: 0;
}

.pw-wrap {
  position: relative;
}

.pw-wrap > input {
  padding-right: 48px;
  margin-bottom: 0;
}

.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.pw-toggle:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.pw-toggle svg {
  width: 18px;
  height: 18px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding-top: var(--space-4);
  margin-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.form-actions.is-sticky {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding-bottom: var(--space-4);
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* ---- Tables --------------------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table .r,
.data-table th.r {
  text-align: right;
}

.data-table th a {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.data-table th a:hover,
.data-table th a.sorted {
  color: var(--primary-dark);
}

.table-empty td {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--text-muted);
}

.table-wrapper .pagination {
  margin-top: 0;
  padding: var(--space-3) var(--space-4);
}

.empty-state .icon-tile {
  margin: 0 auto var(--space-4);
}

/* ---- Page head ------------------------------------------------------------ */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.page-head h1 {
  margin: 0;
}

.page-head .eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary-hover);
  margin-bottom: var(--space-1);
}

.page-head .sub {
  color: var(--text-muted);
  margin: var(--space-2) 0 0;
}

.page-head .actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ---- Breadcrumb ----------------------------------------------------------- */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 var(--space-2);
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.crumbs a {
  color: var(--text-secondary);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

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

.crumbs [aria-current] {
  color: var(--text-main);
  font-weight: 600;
  max-width: 40ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Previous / next pager ------------------------------------------------ */
.pager-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.pager-nav > a,
.pager-nav > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: var(--text-main);
  text-decoration: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.pager-nav > a:hover {
  border-color: var(--primary);
  background: var(--primary-lightest);
}

.pager-nav .is-next {
  text-align: right;
}

.pager-nav > .is-next:only-child {
  grid-column: 2;
}

.pager-nav .dir {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary-hover);
}

.pager-nav .name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pager-nav .is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.pager-nav .is-disabled .dir {
  color: var(--text-muted);
}

/* ---- Course context bar (Topic / Video / Quiz / Material) ------------------ */
.course-bar {
  position: sticky;
  top: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 10px var(--space-4);
  margin-bottom: var(--space-6);
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.course-bar .cb-title {
  min-width: 0;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-bar .cb-lesson {
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

.course-bar .cb-progress {
  flex: 1;
  min-width: 80px;
}

.course-bar .cb-pct {
  font-size: var(--text-sm);
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.course-bar .btn {
  flex-shrink: 0;
}

/* ---- Chips (state labels) ------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.chip::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.chip-plain::before {
  display: none;
}

.chip-enrolled, .chip-success, .chip-resolved {
  background: var(--success-light);
  color: var(--success-dark);
}

.chip-expired, .chip-neutral {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.chip-locked {
  background: var(--bg-muted);
  color: var(--text-main);
}

.chip-releases, .chip-warning {
  background: var(--warning-light);
  color: var(--warning-dark);
}

.chip-overdue, .chip-urgent, .chip-danger {
  background: var(--danger-light);
  color: var(--danger-dark);
}

.chip-info {
  background: var(--info-light);
  color: var(--info-dark);
}

.chip-primary {
  background: var(--primary-lighter);
  color: var(--primary-dark);
}

/* ---- Confirm dialog (astory-ui.js builds it on .modal-overlay) ------------- */
.confirm-dialog .modal-box {
  max-width: 460px;
  padding: var(--space-6);
}

.confirm-dialog h3 {
  margin-bottom: var(--space-2);
}

.confirm-dialog p {
  white-space: pre-line;
  margin-bottom: var(--space-6);
}

.confirm-dialog .modal-actions {
  flex-wrap: wrap;
}

body.modal-open {
  overflow: hidden;
}

/* ---- Tiles ---------------------------------------------------------------- */
.stat-tile {
  min-width: 0;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

.stat-tile .label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-tile .value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 600;
  line-height: 1.15;
  color: var(--text-main);
  margin-top: var(--space-1);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.stat-tile .sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.icon-tile {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-lg);
  background: var(--primary-lighter);
  color: var(--primary);
}

.icon-tile svg {
  width: 50%;
  height: 50%;
}

.icon-tile.sm { width: 36px; height: 36px; border-radius: var(--radius-md); }
.icon-tile.lg { width: 72px; height: 72px; border-radius: var(--radius-xl); }
.icon-tile.success { background: var(--success-light); color: var(--success-dark); }
.icon-tile.warning { background: var(--warning-light); color: var(--warning-dark); }
.icon-tile.danger  { background: var(--danger-light);  color: var(--danger-dark); }
.icon-tile.info    { background: var(--info-light);    color: var(--info-dark); }

/* ---- Loading buttons: make the existing .btn.loading spinner visible -------- */
.btn.loading {
  cursor: progress;
}

.btn.loading::after {
  width: 18px;
  height: 18px;
  border-color: rgba(255, 255, 255, 0.95);
  border-top-color: transparent;
}

.btn-secondary.loading::after,
.btn-ghost.loading::after {
  border-color: var(--primary);
  border-top-color: transparent;
}

/* ---- Footer and maintenance banner ---------------------------------------- */
.footer-contact a {
  color: var(--text-light);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color var(--transition-fast);
}

.footer-contact a:hover {
  color: var(--text-inverse);
}

.maintenance-banner {
  background: var(--warning-light);
  color: var(--warning-dark);
  border-bottom: 1px solid #fcd34d;
  padding: 10px var(--space-4);
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 600;
}

.maintenance-banner a {
  color: inherit;
  text-decoration: underline;
  margin-left: 6px;
}

/* ---- Responsive ----------------------------------------------------------- */
@media (max-width: 1024px) {
  .container {
    padding: var(--space-8) var(--space-5);
  }
}

@media (max-width: 768px) {
  .container {
    padding: var(--space-6) var(--space-4);
  }

  .course-bar {
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
  }

  .course-bar .cb-title {
    flex-basis: 100%;
  }

  .course-bar .cb-progress {
    order: 5;
    flex-basis: 100%;
  }
}

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

  .pager-nav .is-next {
    text-align: left;
  }

  .pager-nav > .is-next:only-child {
    grid-column: auto;
  }

  .stat-tile .value {
    font-size: var(--text-2xl);
  }

  .confirm-dialog .modal-actions .btn {
    flex: 1;
  }
}

/* ---- Reduced motion ------------------------------------------------------- */
/* Animations still finish (so fade-in elements end visible), just instantly. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- Print (invoices, records) ------------------------------------------- */
@media print {
  .navbar, .footer, .skip-link, .maintenance-banner, .nav-hamburger,
  .modal-overlay, .no-print, .btn {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .container, .container.container-admin {
    max-width: none;
    padding: 0;
  }

  .card {
    box-shadow: none;
    break-inside: avoid;
  }

  [class*="animate-fadeIn"], [class*="animate-slideIn"] {
    opacity: 1 !important;
    animation: none !important;
  }

  a {
    color: inherit;
  }
}

/* =============================================================================
   STAGE 82 - PHASE B (dashboard, account, sign-in and status pages)
   Button colours, the welcome card and the wallet are unchanged.
   ============================================================================= */

/* ---- Content widths ------------------------------------------------------- */
.content-narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
.content-medium { max-width: 920px; margin-left: auto; margin-right: auto; }
.content-wide   { max-width: 1100px; margin-left: auto; margin-right: auto; }

/* Vertical rhythm for stacked sections inside a card */
.stack > * + * { margin-top: var(--space-6); }
.stack-sm > * + * { margin-top: var(--space-3); }

/* ---- Section head: heading with an optional action on the right ----------- */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.section-head h2,
.section-head h3 {
  margin: 0;
}

.section-head h2 {
  font-size: var(--text-xl);
}

.section-head .section-head__meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ---- Panels and label/value grids ---------------------------------------- */
.panel {
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.panel + .panel { margin-top: var(--space-4); }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin: 0;
}

.kv { min-width: 0; margin: 0; }

.kv-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 2px;
}

.kv-value {
  font-weight: 600;
  color: var(--text-main);
  overflow-wrap: anywhere;
  margin: 0;
}

/* A row with details on the left and actions on the right (profile contact rows) */
.split-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-4);
  align-items: center;
}

.split-row__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

@media (max-width: 560px) {
  .split-row { grid-template-columns: 1fr; }
  .split-row__actions { justify-content: flex-start; }
}

/* ---- Rows of buttons and inline forms ------------------------------------- */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.btn-row > form { margin: 0; }

.btn-row.is-end { justify-content: flex-end; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0;
}

.inline-form > input,
.inline-form > select {
  flex: 1 1 220px;
  margin: 0;
}

/* Disabled buttons look disabled (colours unchanged, just faded) */
.btn:disabled:not(.loading),
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: none;
}

.form-row > .form-field { margin-bottom: 0; }
.form-row + .form-field,
.form-row + .form-row { margin-top: var(--space-5); }
.form-row { margin-bottom: var(--space-5); }

.form-field .optional {
  font-weight: 400;
  color: var(--text-muted);
}

.req { color: var(--danger); }

.hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Honeypot field for bots: off-screen, never display:none (some bots skip hidden fields) */
.honeypot {
  position: absolute !important;
  left: -10000px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
}

/* ---- Choice cards (radio / checkbox options) ------------------------------ */
.choice-list {
  display: grid;
  gap: var(--space-3);
  margin: 0 0 var(--space-5);
  padding: 0;
  border: 0;
}

.choice-list.is-row { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.choice-list > legend {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-main);
  margin-bottom: var(--space-2);
  padding: 0;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none; /* Stage 99: <a class="choice"> (SignupCourse join choices) must not show the link underline */
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.choice:hover { border-color: var(--primary-light); }

.choice input[type="radio"],
.choice input[type="checkbox"] {
  margin: 3px 0 0;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.choice:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-lightest);
  box-shadow: 0 0 0 1px var(--primary);
}

.choice:has(input:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.choice__title {
  display: block;
  font-weight: 600;
  color: var(--text-main);
}

.choice__desc {
  display: block;
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Choice buttons that show / hide a panel (SignupCourse "How would you like to join?") */
button.choice {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
}

button.choice[aria-pressed="true"], a.signup-choice[aria-current="true"] {
  border-color: var(--primary);
  background: var(--primary-lightest);
  box-shadow: 0 0 0 1px var(--primary);
}

.choice .icon-tile { width: 40px; height: 40px; }

/* ---- Callout (highlighted offer / promotion panel) ------------------------- */
.callout {
  display: block;
  padding: var(--space-5);
  border: 1px solid #fcd34d;
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-lg);
  background: #fffbeb;
  color: var(--text-main);
  margin-bottom: var(--space-6);
}

a.callout {
  text-decoration: none;
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}

a.callout:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.callout__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.callout__title {
  font-weight: 700;
  color: var(--warning-dark);
  margin: 0 0 var(--space-1);
}

.callout p { margin: 0; color: var(--text-secondary); }

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  margin: var(--space-5) 0;
}

.callout .stat-tile { background: rgba(255, 255, 255, 0.75); }

.price-was {
  text-decoration: line-through;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---- Small helpers --------------------------------------------------------- */
.cell-ellipsis {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ref-code {
  font-family: Consolas, 'Courier New', monospace;
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
}

.lead {
  font-size: var(--text-lg);
  color: var(--text-secondary);
}

.text-warning { color: var(--warning-dark); }

.balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.balance-grid .stat-tile .value { font-size: var(--text-2xl); }

.stat-tile .value.is-primary { color: var(--primary); }
.stat-tile .value.is-secondary { color: var(--secondary); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-6);
  align-items: stretch;
}

.card-grid > .card { margin-bottom: 0; display: flex; flex-direction: column; }
.card-grid > .card > form:last-child { margin-top: auto; }

.feature-list {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
  color: var(--text-secondary);
}

.feature-list li + li { margin-top: var(--space-1); }

/* ---- Dashboard: continue strip and lesson progress ------------------------ */
.dash-continue {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.dash-continue__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.dash-continue__label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary-hover);
}

.dash-continue__title {
  font-weight: 700;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-continue__meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-continue .btn { flex-shrink: 0; }

@media (max-width: 480px) {
  .dash-continue { flex-wrap: wrap; }
  .dash-continue .btn { width: 100%; }
}

.course-progress {
  margin-top: var(--space-4);
}

.course-progress .progress-bar { height: 6px; }

.course-progress__caption {
  display: block;
  margin-top: 6px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

/* ---- Sign-in, registration and verification cards ------------------------- */
.auth-card.is-wide { max-width: 820px; }
.auth-card.is-medium { max-width: 560px; }

.auth-card > .card { text-align: left; }

.auth-head {
  text-align: center;
  margin-bottom: var(--space-6);
}

.auth-head .icon-tile {
  margin: 0 auto var(--space-4);
  background: var(--gradient-card);
  color: var(--text-inverse);
  box-shadow: var(--shadow-glow);
}

.auth-head h1 {
  margin-bottom: var(--space-2);
}

.auth-head p {
  margin: 0;
  color: var(--text-secondary);
}

.auth-tabs {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  margin-bottom: var(--space-5);
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
}

.auth-tabs button {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.auth-tabs button:hover { color: var(--primary-hover); }

.auth-tabs button[aria-pressed="true"] {
  background: var(--bg-card);
  color: var(--primary-hover);
  box-shadow: var(--shadow-sm);
}

.auth-footer {
  margin-top: var(--space-6);
  text-align: center;
}

.auth-footer .auth-divider { margin-top: 0; }

.phone-row {
  display: grid;
  grid-template-columns: minmax(110px, 140px) minmax(0, 1fr);
  gap: var(--space-3);
}

.phone-row > select,
.phone-row > input { margin-bottom: 0; }

.form-actions.is-split { justify-content: space-between; }
.form-actions.is-plain { border-top: 0; padding-top: 0; }
.form-actions.is-stretch > .btn { flex: 1 1 auto; }

.form-section + .form-section {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}

.form-section__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.form-section__head h2 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.terms-box {
  padding: var(--space-4);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-5);
}

.check-line {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  font-weight: 500;
  cursor: pointer;
}

.check-line + .check-line { margin-top: var(--space-3); }

.check-line input { margin: 4px 0 0; flex-shrink: 0; accent-color: var(--primary); }

/* Address lookup suggestions (reg.php, SignupCourse.php; address-lookup.js) */
.suggest { position: relative; }

.suggest-list {
  position: absolute;
  z-index: 50;
  top: calc(100% - var(--space-3));
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.suggest-item {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  cursor: pointer;
}

.suggest-item:hover,
.suggest-item.is-active { background: var(--primary-lightest); }

.address-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.address-row > .suggest { flex: 1; min-width: 0; }
.address-row > .btn { flex-shrink: 0; }

/* One-time code input */
.otp-input {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: 0.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---- Status pages (errors, payment result, maintenance) ------------------- */
.status-page {
  max-width: 560px;
  margin: var(--space-10) auto;
}

.status-page > .card {
  text-align: center;
  padding: var(--space-10) var(--space-8);
}

.status-page .icon-tile {
  margin: 0 auto var(--space-5);
}

.status-page h1 {
  margin-bottom: var(--space-3);
}

.status-page .lead {
  margin-bottom: var(--space-6);
  overflow-wrap: anywhere;
}

.status-page .btn-row { justify-content: center; }

.status-page .msg { text-align: left; }

.status-page .status-extra { margin-top: var(--space-6); text-align: left; }

@media (max-width: 480px) {
  .status-page > .card { padding: var(--space-8) var(--space-5); }
  .status-page .btn-row > .btn,
  .status-page .btn-row > form,
  .status-page .btn-row > form > .btn { width: 100%; }
}

/* ---- Support threads ------------------------------------------------------ */
.support-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.support-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
  font-size: var(--text-base);
  line-height: 1.65;
  margin: 0;
  color: var(--text-main);
}

.support-thread {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.support-reply {
  padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
}

.support-reply-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.support-reply-head strong { color: var(--text-main); }

/* ---- Invoices ------------------------------------------------------------- */
.invoice-sheet {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.inv-sub {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.bank-details {
  width: 100%;
  margin-bottom: var(--space-4);
}

.bank-details th {
  width: 40%;
  background: transparent;
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.bank-details td { font-weight: 600; }

@media print {
  .invoice-sheet,
  .invoice-sheet.card {
    max-width: none;
    border: 0;
    padding: 0;
  }

  .page-head,
  .crumbs {
    display: none !important;
  }
}

/* ---- Phase B: page details ------------------------------------------------ */
.inv-sub.is-danger { color: var(--danger-dark); font-weight: 600; }

.section-note {
  margin: var(--space-3) 0 0;
  color: var(--text-muted);
}

.modal-notes p { margin: var(--space-2) 0 0; }
.modal-notes { margin-bottom: var(--space-5); }
.modal-box .bank-details { margin: var(--space-2) 0 var(--space-3); }
.modal-box .bank-details th,
.modal-box .bank-details td { padding: 6px 12px 6px 0; }
.section-gap { margin-top: var(--space-6); }
.break-all { word-break: break-all; }
.text-success { color: var(--success-dark); }
.text-danger { color: var(--danger-dark); }

/* Icons inside buttons (pages no longer size them inline) */
.btn > svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-sm > svg { width: 14px; height: 14px; }
.content-form { max-width: 600px; margin-left: auto; margin-right: auto; }
.choice-list[hidden], [hidden].hint { display: none; }
.stat-tile .value { overflow-wrap: anywhere; }
.content-narrow-left { max-width: 760px; }
.d-block { display: block; }
.card-grid { margin-bottom: var(--space-6); }
.mb-0 { margin-bottom: 0; }
.break-word { overflow-wrap: anywhere; }
.min-w-0 { min-width: 0; }

/* Password show/hide (sys/FormView.php form_password_toggle, astory-ui.js) */
.pw-toggle .pw-icon-hide { display: none; }
.pw-toggle[aria-pressed="true"] .pw-icon-show { display: none; }
.pw-toggle[aria-pressed="true"] .pw-icon-hide { display: block; }
.pw-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.captcha-img {
  display: block;
  margin-bottom: var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
}

.forgot-link {
  display: block;
  text-align: right;
  font-size: var(--text-sm);
  margin: calc(-1 * var(--space-3)) 0 var(--space-4);
}
.suggest-list { top: calc(100% + 4px); }
.auth-card .msg { text-align: left; }
.auth-card > .msg { margin-bottom: var(--space-5); }
.auth-card .form-section { text-align: left; }
.btn-row.is-centered { justify-content: center; }
.status-page-banner { max-width: 560px; margin: 0 auto; }
.status-page .status-extra .lead { margin-bottom: var(--space-6); }
.signup-side { min-width: 0; }
.signup-fee { text-align: center; }
.plan-table td { padding: 8px 0; background: transparent; }
.plan-table tr:hover { background: transparent; }
.choice-list > .kv-label { margin-bottom: 0; }

/* Plain text links: indigo (style.css never set a link colour, so pages fell back to browser blue).
   Buttons, nav, footer, breadcrumbs and cards keep their own colours through their classes. */
a {
  color: var(--primary-hover);
  text-underline-offset: 2px;
}

a:where(:not(.btn)):hover {
  color: var(--primary-dark);
}

.data-table a:not(.btn),
.forgot-link,
.auth-footer a:not(.btn) {
  font-weight: 600;
  text-decoration: none;
}

.data-table a:not(.btn):hover,
.forgot-link:hover,
.auth-footer a:not(.btn):hover {
  text-decoration: underline;
}

/* =============================================================================
   STAGE 82 - PHASE C (student learning flow)
   Button colours are unchanged: new classes only replace inline overrides with the same colours.
   ============================================================================= */
:root {
  --gold: #c9a227;
  --hero-navy: linear-gradient(135deg, #0b1220 0%, #1e3a8a 100%);
}

/* ---- Navbar "Register" button: readable white text ------------------------ */
/* .nav-links a (0,1,1) used to beat .btn (0,1,0), giving slate text on the indigo button,
   and .nav-links a:hover swapped the button for a pale lavender pill. */
.nav-links a.btn:not(.btn-ghost),
.nav-links a.btn:not(.btn-ghost):hover {
  color: var(--text-inverse);
  background: var(--gradient-card);
}

/* ---- Small shared pieces --------------------------------------------------- */
.progress-fill.is-gold { background: var(--gold); }

.cb-spacer { flex: 1; }

h1.has-icon, h2.has-icon, h3.has-icon {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

h1.has-icon > svg { width: 30px; height: 30px; color: var(--primary); flex-shrink: 0; }
h2.has-icon > svg { width: 24px; height: 24px; color: var(--primary); flex-shrink: 0; }
h3.has-icon > svg { width: 20px; height: 20px; color: var(--primary); flex-shrink: 0; }

/* Mode of delivery label: group courses red, self-paced blue (same colours as before) */
.mode-chip {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid currentColor;
  border-radius: 4px;
  background: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.mode-chip.is-group { color: var(--danger); }
.mode-chip.is-self { color: var(--info); }

/* Disabled buttons (expired course): white, faded, no hover change; the title tooltip still shows */
.btn.is-disabled,
.btn.is-disabled:hover {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-muted);
  transform: none;
  box-shadow: none;
  filter: none;
  cursor: not-allowed;
}

a.chip { text-decoration: none; }
a.chip:hover { filter: brightness(0.96); text-decoration: underline; }

/* ---- Dashboard "My Courses": two cards per row ---------------------------- */
.my-course-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
}

.my-course-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.my-course-card .course-progress { margin-top: 0; }

.my-course-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}

.my-course-card__head h3 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xl);
  overflow-wrap: anywhere;
}

.my-course-card__head > .chip { flex-shrink: 0; }

.my-course-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Stage 91: exam date on the course card - the same red as the calendar's Exam dot */
.course-exam-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #b91c1c;
}
.course-exam-date__dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
}

.my-course-card__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin-top: auto;
}

.my-course-card__actions > .btn { width: 100%; }

.my-course-card.is-expired { opacity: 0.85; }
.my-course-card.is-expired:hover { border-color: var(--border); }

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

@media (max-width: 400px) {
  .my-course-card__actions { grid-template-columns: 1fr; }
}

/* ---- Course hero (CourseHome.php): dark navy card ------------------------- */
.course-hero {
  background: var(--hero-navy);
  color: var(--text-inverse);
  border: 0;
}

.course-hero:hover { box-shadow: var(--shadow-sm); }

.course-hero__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}

.course-hero__main { flex: 1 1 360px; min-width: 0; }

.course-hero h1 {
  color: var(--text-inverse);
  font-size: var(--text-3xl);
  margin: var(--space-3) 0 var(--space-2);
  overflow-wrap: anywhere;
}

.course-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin: 0 0 var(--space-4);
  color: #c7d2fe;
  font-size: var(--text-sm);
}

.course-hero__meta > span + span::before {
  content: '\00B7';
  margin-right: var(--space-2);
  color: #a5b4fc;
}

.course-hero__meta a { color: var(--text-inverse); text-decoration: underline; }
.course-hero__meta a:hover { color: var(--text-inverse); }
.course-hero__meta strong { color: var(--text-inverse); font-weight: 600; }

.course-hero__progress { max-width: 440px; }

.course-hero__progress .progress-bar { background: rgba(255, 255, 255, 0.18); }

.course-hero__caption {
  margin: 6px 0 0;
  font-size: var(--text-sm);
  color: #c7d2fe;
}

.course-hero__caption a { color: var(--text-inverse); font-weight: 600; text-decoration: underline; }
.course-hero__caption a:hover { color: var(--text-inverse); }

/* Stage 91: estimated study score (Year 12 courses) */
.course-hero__score {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  margin: var(--space-3) 0 0;
  padding: var(--space-2) var(--space-4);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.10);
}
.course-hero__score-label { font-size: var(--text-sm); color: #c7d2fe; }
.course-hero__score-value { font-size: var(--text-xl); font-weight: 700; color: var(--text-inverse); }
.course-hero__score.is-pending .course-hero__score-value { font-size: var(--text-base); font-weight: 600; color: #e0e7ff; }

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 0 0 240px;
}

.hero-actions > .btn { width: 100%; }

.chip-on-dark {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-inverse);
}

/* Buttons on dark cards: the same colours CourseHome used to set inline */
.btn-on-dark {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-inverse);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: none;
}

/* Hover keeps the same colours (the inline styles they replace did not change on hover) */
.btn-on-dark:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-inverse);
}

.btn-on-dark.is-solid {
  background: #fff;
  color: var(--primary);
  border-color: #fff;
}

.btn-on-dark.is-solid:hover {
  background: #fff;
  color: var(--primary);
}

@media (max-width: 768px) {
  .hero-actions { flex-basis: 100%; }
}

/* ---- Section cards (CourseHome.php sections) ------------------------------ */
.section-card {
  --accent: var(--primary);
  border-top: 3px solid var(--accent);
}

.section-card.is-warning { --accent: var(--warning); }
.section-card.is-info { --accent: var(--info); }
.section-card.is-success { --accent: var(--success); }
.section-card.is-danger { --accent: var(--danger); }
.section-card.is-secondary { --accent: var(--secondary); }

.section-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.section-card__head h2,
.section-card__head h3 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: 700;
}

.section-card__icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 14%, white);
  color: var(--accent);
}

.section-card__icon svg { width: 18px; height: 18px; }

.section-card__head .spacer { margin-left: auto; }

.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

.section-grid > .card { margin-bottom: 0; min-width: 0; }
.section-grid > .card:only-child { grid-column: 1 / -1; }

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

/* A sub-group heading inside a section card (e.g. "Week 1" materials) */
.section-group + .section-group { margin-top: var(--space-5); }

.section-group__title {
  margin: 0 0 var(--space-2);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* List rows inside section cards */
.resource-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.resource-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  transition: background var(--transition-base), border-color var(--transition-base);
}

.resource-row:hover { background: var(--bg-muted); }

.resource-row.is-locked { opacity: 0.8; }
.resource-row.is-locked:hover { background: var(--bg-subtle); }

.resource-row__main {
  flex: 1 1 220px;
  min-width: 0;
}

.resource-row__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  color: var(--text-main);
  overflow-wrap: anywhere;
}

.resource-row__meta {
  margin-top: 2px;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.resource-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  flex-shrink: 0;
}

.empty-line {
  margin: 0;
  color: var(--text-muted);
  font-style: italic;
}

/* Neutral chips stay visible on the grey list rows */
.resource-row .chip-neutral,
.resource-row .chip-expired { background: var(--bg-card); }

.chip > svg { width: 12px; height: 12px; flex-shrink: 0; }
.chip:has(> svg)::before { display: none; }

.section-title {
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: 700;
  margin: 0 0 var(--space-2);
}

.has-icon > svg { flex-shrink: 0; }

.resource-row__meta.has-icon {
  display: flex;
  align-items: center;
  gap: 6px;
}

.resource-row__meta.has-icon > svg { width: 13px; height: 13px; }

/* ---- Course Map (CourseMap.php) ------------------------------------------ */
.map-progress {
  max-width: 520px;
  margin: calc(-1 * var(--space-2)) 0 var(--space-6);
}

.map-lessons {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.map-lesson {
  margin-bottom: 0;
  border-top: 3px solid var(--primary);
  scroll-margin-top: var(--space-4);
}

.map-lesson.is-locked { border-top-color: var(--warning); }

.map-lesson__summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  list-style: none;
  cursor: pointer;
}

.map-lesson__summary::-webkit-details-marker { display: none; }

.map-lesson__main { flex: 1; min-width: 0; }

.map-lesson__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.map-lesson__title h2 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.map-lesson__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.map-lesson__detail {
  margin-top: var(--space-3);
  color: var(--text-muted);
  line-height: 1.6;
}

.map-lesson__toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-lighter);
  color: var(--primary-dark);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
}

.map-lesson__toggle svg {
  width: 14px;
  height: 14px;
  transition: transform var(--transition-base);
}

.map-lesson[open] .map-lesson__toggle svg { transform: rotate(180deg); }
.map-lesson .when-open,
.map-lesson[open] .when-closed { display: none; }
.map-lesson[open] .when-open { display: inline; }

.map-lesson__summary:hover .map-lesson__toggle { background: var(--primary-light); }

.map-lesson__topics {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

@media (max-width: 560px) {
  .map-lesson__summary { flex-direction: column; }
}

.chip-secondary {
  background: var(--secondary-lighter);
  color: var(--secondary-hover);
}

/* ---- Topic page (CourseTopic.php) ----------------------------------------- */
.topic-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
}

.topic-head__main { flex: 1 1 320px; min-width: 0; }

.topic-head h1 {
  margin: 0 0 var(--space-3);
  overflow-wrap: anywhere;
}

.topic-head__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.topic-detail__text {
  color: var(--text-secondary);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.callout__title.has-icon {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.callout__title.has-icon > svg { width: 18px; height: 18px; }

/* The pager closes the page; keep it clear of the footer */
.section-card + .pager-nav,
.card + .pager-nav,
.callout + .pager-nav { margin-top: var(--space-2); }

.pager-nav .name .chip { vertical-align: middle; }

/* Compact pager (Video.php sidebar) */
.pager-nav.is-compact { gap: var(--space-2); }

.pager-nav.is-compact > a,
.pager-nav.is-compact > span {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.pager-nav.is-compact .dir { text-transform: none; letter-spacing: 0; }

.pager-nav.is-compact .name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.pager-nav.is-compact .name .chip {
  white-space: normal;
  padding: 1px 6px;
  font-size: 0.6875rem;
}

.vp-page > .course-bar,
.vp-page > .crumbs { margin-bottom: 0; }

/* On phones the course bar wraps to three lines; let it scroll away instead of covering the page */
@media (max-width: 768px) {
  .course-bar { position: static; }
}

/* ---- Material page (MaterialDetail.php) ----------------------------------- */
.content-wide-left { max-width: 1000px; }

.material-frame {
  margin-top: var(--space-3);
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  overflow: auto;
  line-height: 1.7;
}

/* ---- Course catalogue (Courses.php) --------------------------------------- */
.diag-pre { white-space: pre-wrap; overflow-wrap: anywhere; }

.legend-list { margin: 0; padding-left: 1.2rem; }
.legend-list li + li { margin-top: var(--space-1); }

.course-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.filter-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
}

.filter-tab {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-weight: 400;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-base);
}

.filter-tab:last-child { border-right: 0; }
.filter-tab.filter-active { background: var(--primary-lighter); color: var(--primary); font-weight: 600; }
.filter-tab:hover:not(.filter-active) { background: var(--bg-subtle); color: var(--text-main); }

@media (max-width: 640px) {
  .filter-tabs { flex-wrap: wrap; }
  .filter-tab { flex: 1 1 33%; border-bottom: 1px solid var(--border); }
}

.course-pagination {
  margin-top: var(--space-6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.course-pagination[hidden] { display: none; }

.course-page-numbers {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.course-page-btn { min-width: 40px; }
.course-page-btn[aria-current="page"] { background: var(--primary); color: #fff; border-color: var(--primary); cursor: default; }
.course-page-status { padding: 0 var(--space-2); }

.class-card { display: flex; flex-direction: column; min-width: 0; }
.class-card[hidden] { display: none; }
.class-card-actions { margin-top: auto; padding-top: var(--space-4); }
.class-card.is-expired { opacity: 0.85; }

.class-card-header { gap: var(--space-3); }

.class-card-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-1);
  flex-shrink: 0;
}

.class-card-facts { margin-bottom: var(--space-4); }

.fact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.fact-row + .fact-row { margin-top: var(--space-1); }
.capacity-bar + .fact-row { margin-top: var(--space-2); }

.avail-open { color: var(--success); }
.avail-few { color: var(--warning); }
.avail-one { color: var(--danger); font-weight: 700; }
.avail-full { color: var(--danger); font-weight: 800; }
.avail-disabled { color: var(--text-muted); font-weight: 700; }

.price-now { color: var(--danger); font-weight: 700; }

.class-card-meta .has-icon { display: inline-flex; align-items: center; gap: 4px; }
.class-card-meta .has-icon > svg { width: 14px; height: 14px; }

.class-card-actions > form { margin: 0; }
.class-card-actions .btn > svg { width: 14px; height: 14px; }

.course-search-wrap svg { width: 18px; height: 18px; }

/* ---- Course details (CourseDetails.php, SignupCourse.php; sys/CourseDetailsView.php) ---- */
.page-head--compact { align-items: center; margin-bottom: var(--space-4); }
.page-head--compact .eyebrow { margin: 0; }

.details-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: var(--space-6);
  align-items: start;
}

.details-layout > * { min-width: 0; }
.details-main > .card,
.details-side > .card { margin-bottom: 0; }

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

.details-side__card { position: sticky; top: var(--space-6); }

@media (max-width: 900px) {
  .details-side__card { position: static; }
}

.details-head { margin-bottom: var(--space-6); }
.details-head > .chip { margin-bottom: var(--space-3); }

.details-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-2xl);
  overflow-wrap: anywhere;
}

.details-tutor {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.avatar-initial {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--primary-lighter);
  color: var(--primary);
  font-weight: 700;
  font-size: var(--text-sm);
}

.details-tutor__link,
.details-tutor__name { color: var(--text-main); font-weight: 700; }

.details-mode {
  margin: 4px 0 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.details-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.details-fact {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  text-align: center;
}

.details-fact > svg {
  width: 22px;
  height: 22px;
  margin-bottom: var(--space-2);
  color: var(--text-muted);
}

.details-fact > svg.is-primary { color: var(--primary); }

.details-fact__value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-main);
}

.details-fact__value.is-primary { color: var(--primary); }

@media (max-width: 480px) {
  .details-facts { gap: var(--space-2); }
  .details-fact { padding: var(--space-3) var(--space-2); }
  .details-fact__value { font-size: var(--text-lg); }
}

.details-line {
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
}

.details-line__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.details-line__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  color: var(--text-secondary);
}

.details-line__label > svg { width: 20px; height: 20px; }

.details-line__value {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-main);
}

.details-line__value.is-primary { color: var(--primary); }
.details-line__value.is-danger { color: var(--danger); }

.details-description {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.fee-box { text-align: center; margin-bottom: var(--space-6); }
.wallet-balance.is-was { font-size: var(--text-2xl); text-decoration: line-through; color: var(--text-muted); }

.balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.balance-row .wallet-label { margin: 0; }

.button-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

#joinForm { margin: 0; }

.plan-option { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.plan-option-title { font-weight: 700; margin-bottom: var(--space-2); }
.plan-option form { margin: 0; }
.plan-table--lined { width: 100%; border-collapse: collapse; font-size: var(--text-sm); margin-bottom: var(--space-2); }
.plan-table--lined td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.plan-table--lined tr:last-child td { border-bottom: 0; }
.plan-amount { text-align: right; font-weight: 600; }
.plan-note { margin: var(--space-2) 0; }
.plan-consent { margin: var(--space-2) 0 var(--space-3); font-weight: 400; }

.mt-1 { margin-top: var(--space-1); }

/* ---- Ask Tutor (AskTutor.php, AskList.php, AskView.php) ------------------- */
.ask-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

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

.wallet-balance.is-secondary { color: var(--secondary); }

.sub-coins-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: #16a34a;
  font-weight: 700;
}

.sub-coins { color: #16a34a; font-weight: 700; }

.urgency-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.urgency-option {
  display: flex;
  flex: 1 1 220px;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  font-weight: 400;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.urgency-option.selected-nonurgent { border-color: var(--primary); background: var(--primary-lighter); }
.urgency-option.selected-urgent { border-color: var(--danger); background: var(--danger-light); }

.ask-token-msg { margin-top: var(--space-3); color: var(--text-secondary); }

#askFieldsCard, #questionFieldWrap, #attachmentFieldWrap { transition: opacity 200ms ease; }

.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

.attach-list { margin-top: 10px; }

.attach-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
}

.attach-item__name { font-weight: 600; overflow-wrap: anywhere; }

.data-table tr.is-urgent-row { background: rgba(239, 68, 68, 0.05); box-shadow: inset 3px 0 0 var(--danger); }

.ask-box {
  margin: 0 0 var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
}

.ask-box.is-empty { color: var(--text-muted); font-style: italic; }

.ask-subtitle {
  margin: var(--space-5) 0 var(--space-3);
  font-size: 1.05rem;
}

.ask-coins { margin: 6px 0 0; line-height: 1.5; }
.ask-rating-hint { margin: calc(-1 * var(--space-3)) 0 var(--space-5); }

/* ---- Tutor profile (TutorProfile.php) -------------------------------------- */
.tutor-profile-card {
  max-width: 1000px;
  margin: 0 auto;
  overflow: hidden;
}

.tutor-profile-grid {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: var(--space-6);
  align-items: start;
}

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

.tutor-profile-side {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--primary-lighter), rgba(255, 255, 255, 0));
  text-align: center;
}

.tutor-photo {
  display: block;
  width: 180px;
  height: 180px;
  margin: 0 auto var(--space-4);
  border: 4px solid #fff;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  object-fit: cover;
}

.tutor-photo.is-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--primary);
  color: #fff;
  font-size: 72px;
  font-weight: 800;
}

.tutor-name { margin: 0 0 var(--space-2); font-size: var(--text-3xl); overflow-wrap: anywhere; }

.tutor-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: var(--space-4);
}

.tutor-facts {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
  text-align: left;
}

.tutor-facts .panel + .panel { margin-top: 0; }
.tutor-fact__value { font-size: var(--text-xl); font-weight: 700; }

.tutor-motto {
  margin-bottom: var(--space-4);
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  background: var(--bg-subtle);
}

.tutor-motto .wallet-label { margin-bottom: var(--space-2); }

.tutor-motto__text {
  margin: 0;
  font-size: var(--text-lg);
  font-style: italic;
  line-height: 1.7;
  color: var(--text-main);
}

.tutor-education { margin-bottom: var(--space-5); }

.check-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  line-height: 1.6;
}

.check-list svg { width: 16px; height: 16px; margin-top: 3px; flex-shrink: 0; color: var(--success); }

/* ---- Announcement page (AnnoDetails.php) ---------------------------------- */
.anno-body {
  font-size: var(--text-base);
  line-height: 1.8;
  color: var(--text-main);
  overflow-wrap: anywhere;
}

/* =============================================================================
   STAGE 82 PHASE D: MOBILE AND ACCESSIBILITY SWEEP
   No animation, hover effect, button colour (apart from green and red, owner approved) or
   layout above 1024px changes here.
   ============================================================================= */

/* ---- Helpers ---------------------------------------------------------------- */
/* An h2 that keeps the look of an h3 (heading order fixed without a visual change) */
.h3 {
  font-family: var(--font-ui);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: normal;
  margin-bottom: var(--space-4);
}

.empty-state .h3 {
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.section-head .h3 { margin: 0; font-size: var(--text-xl); }
.h3.has-icon > svg { width: 20px; height: 20px; }

/* Footer column headings: h2 for the outline, same look as the old h4 */
.footer-heading {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--text-sm);
  line-height: 1.2;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-inverse);
  margin: 0 0 var(--space-4);
}

/* A scroll box for a wide table that has no .table-wrapper card around it */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  position: relative;
}

/* Keeps absolutely positioned content (e.g. .sr-only header text) inside the scroll box,
   so a wide table cannot widen the whole page on a phone. */
.table-wrapper { position: relative; }

/* Scroll boxes get tabindex="0" from astory-ui.js when they actually scroll */
.table-wrapper:focus-visible,
.table-scroll:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---- Text contrast (WCAG AA, 4.5:1 for small text) -------------------------- */
input::placeholder,
textarea::placeholder { color: var(--text-muted); }
.avatar-placeholder { color: var(--text-muted); }
.mode-chip.is-group { color: #dc2626; }
.mode-chip.is-self { color: #2563eb; }
.avail-open { color: #047857; }
.avail-one { color: #b91c1c; }
.req { color: #b91c1c; }
.details-line__value.is-danger { color: #b91c1c; }
.class-card-fee,
.details-fact__value.is-primary,
.details-line__value.is-primary { color: var(--primary-hover); }
.filter-tab.filter-active { color: var(--primary-hover); }
.sub-coins { color: #15803d; }
.nav-unread-badge { background: #dc2626; }
.nav-links a.active { color: var(--primary-hover); }        /* current page in the top bar: 5.1:1 (was 3.6:1) */
.nav-links .nav-admin { color: var(--secondary-hover); }    /* "Admin Panel" link: 5.7:1 (was 4.2:1) */
.admin-badge { color: #6d28d9; }                            /* 6.0:1 on its lilac background (was 3.6:1) */

/* Dimmed rows and cards (expired course, locked topic) keep their fade; the text inside is one
   shade darker so it still reads at 4.5:1 through the fade. */
.my-course-card.is-expired,
.class-card.is-expired { --text-muted: var(--text-secondary); }
.resource-row.is-locked { --text-muted: #334155; }
.is-expired .mode-chip.is-group { color: #b91c1c; }
.is-expired .mode-chip.is-self { color: #1d4ed8; }

/* ---- Tablet (769-1024px): keep the top bar on one line ------------------------ */
@media (min-width: 769px) and (max-width: 1024px) {
  .navbar-inner { padding: 0 var(--space-4); }
  .nav-links a { white-space: nowrap; padding-left: var(--space-2); padding-right: var(--space-2); }
  .nav-divider { margin: 0 var(--space-1); }
  /* The first name stays readable by screen readers; the avatar letter remains visible */
  .nav-user-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ---- Touch targets: at least 44px tall on phones and touch screens --------------
   Desktop with a mouse keeps today's sizes. Where a taller box would change the layout,
   padding plus an equal negative margin enlarges only the tap area. */
@media (max-width: 768px), (pointer: coarse) {
  .btn,
  .filter-tab,
  .method-tab,
  .quiz-hint-toggle,
  .map-lesson__toggle,
  .nav-user-toggle,
  .nav-links .nav-user-menu a,
  .pagination a,
  .pagination button,
  .course-pagination button,
  .pager-nav.is-compact > a,
  .pager-nav.is-compact > span {
    min-height: 44px;
  }

  .map-lesson__toggle,
  .pagination a,
  .course-pagination button { display: inline-flex; align-items: center; }

  .pw-toggle { width: 44px; height: 44px; right: 2px; }
  .nav-hamburger { width: 44px; height: 44px; }
  .quiz-review-close { min-width: 44px; min-height: 44px; }
  .skip-link { padding: 12px var(--space-4); }

  .navbar .brand,
  .footer-brand .brand,
  .course-bar .cb-title,
  a.chip {
    padding-top: 10px;
    padding-bottom: 10px;
    margin-top: -10px;
    margin-bottom: -10px;
  }

  .forgot-link,
  a.small,
  .data-table td > a:not(.btn) {
    display: inline-block;
    padding-top: 12px;
    padding-bottom: 12px;
    margin-top: -12px;
    margin-bottom: -12px;
  }

  .crumbs a { display: inline-block; padding-top: 11px; padding-bottom: 11px; margin-top: -11px; margin-bottom: -11px; }

  /* Footer links stack, so they simply get taller rows */
  .footer-links li { margin-bottom: 0; }
  .footer-links a,
  .footer-contact a { display: inline-flex; align-items: center; min-height: 44px; }
  .footer-contact p { margin-bottom: 0; }
}

/* =============================================================================
   STAGE 91: DASHBOARD PROFILE CARD (replaces the Stage 83 Username / Questions row)
   Questions Completed on the left; "Projected Study Score" list on the right (Year 12 courses only,
   left out when there is nothing to list). One column under 480px.
   ============================================================================= */
.profile-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: var(--space-4);
  align-items: start;
}
.profile-split.is-single { grid-template-columns: minmax(0, 1fr); }
.profile-split > div { min-width: 0; }
.study-score-list {
  list-style: none;
  margin: var(--space-1) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-1);
}
.study-score-list__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}
.study-score-list__subject { min-width: 0; overflow-wrap: anywhere; }
.study-score-list__score { font-weight: 600; white-space: nowrap; }
.study-score-list__row.is-pending .study-score-list__score { font-weight: 400; font-size: var(--text-sm); color: var(--text-muted); }
@media (max-width: 480px) {
  .profile-split { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Stage 85: registration role chooser (reg.php) ------------------------ */
.role-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.role-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: inherit;
  text-decoration: none;
}

.role-choice:hover,
.role-choice:focus-visible {
  border-color: var(--primary-light);
  background: var(--primary-lightest);
  color: inherit;
}

.role-choice__title { font-weight: 700; font-size: var(--text-lg); }
.role-choice__text { color: var(--text-secondary); font-size: var(--text-sm); margin: 0; }

.role-current {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

/* ---- Stage 87: MyChildQuizPerformance.php (parent view of a child's quiz results) ---- */
.my-course-grid.perf-course { grid-template-columns: 1fr; margin-bottom: var(--space-5); }
.perf-course .my-course-card__actions:empty { display: none; }

.perf-group__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
}

.perf-topic {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--text-base);
  overflow-wrap: anywhere;
}
.perf-group__head + .perf-topic { margin-top: var(--space-2); }

.perf-table .nowrap { white-space: nowrap; }
.perf-table .perf-quiz-name { min-width: 14rem; overflow-wrap: anywhere; }
.perf-table .perf-section-row th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
}
.perf-table tr.is-unreleased td { color: var(--text-muted); background: var(--bg-muted); }
.perf-table tr.is-unreleased .chip { opacity: 0.7; }

/* ---- Stage 88: course card banner (Admin/AdminCourseEdit.php "Course Card Background") ---- */
/* The course name sits on it in white (bottom left); sys/CourseCardStyleCommon.php keeps it at 4.5:1. */
.course-card-banner {
  min-height: 84px;
  display: flex;
  align-items: flex-end;
  padding: var(--space-3) var(--space-6);
  margin: calc(-1 * var(--space-6)) calc(-1 * var(--space-6)) var(--space-4);
  border-radius: calc(var(--radius-xl) - 1px) calc(var(--radius-xl) - 1px) 0 0;
  background-color: var(--bg-subtle);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.my-course-card > .course-card-banner { margin-bottom: 0; } /* the card's flex gap already spaces it */
.course-card-banner__title {
  margin: 0;
  color: #fff;
  line-height: 1.25;
  text-shadow: 0 1px 3px rgba(15, 23, 42, 0.55);
  overflow-wrap: anywhere;
}
.my-course-card .course-card-banner__title { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); } /* as .my-course-card__head h3 */

.card-bg-fieldset { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); }
.card-bg-fieldset legend { padding: 0 var(--space-2); }
.card-bg-fieldset [hidden] { display: none !important; }
.card-bg-options { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin: var(--space-3) 0 var(--space-4); }
.card-bg-option { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 600; cursor: pointer; }
.card-bg-option input { width: auto; margin: 0; }

/* Stage 91: AdminCourseEdit "Quizzes Required for 40+" checklist */
.min40-group { margin: 0 0 var(--space-4); }
.min40-group__title { margin: 0 0 var(--space-2); font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); }
.min40-option { display: flex; align-items: flex-start; gap: var(--space-2); margin: 0 0 var(--space-2); font-weight: 400; cursor: pointer; }
.min40-option input { flex: none; width: auto; margin: 3px 0 0; }
.min40-option__id { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.card-bg-color-row { display: flex; align-items: center; gap: var(--space-3); }
.card-bg-color-row input[type="color"] { width: 48px; height: 40px; padding: 2px; cursor: pointer; }
.card-bg-color-row input[type="text"] { max-width: 140px; font-family: var(--font-mono, monospace); }
.card-bg-preview { max-width: 360px; border: 1px solid var(--border); border-radius: var(--radius-xl); padding: var(--space-6); background: var(--bg-card); }
.card-bg-preview-body { color: var(--text-secondary); }

/* ---- Stage 88: Wallet card (sys/WalletView.php - MyWallet.php and the right-side panel) ---- */
/* Same look as the Stage 82 MemberHome card; the inline layout styles became these classes. */
.wallet-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.wallet-card__title { margin: 0; }
.wallet-card__icon { width: 24px; height: 24px; vertical-align: middle; margin-right: 8px; }
.wallet-balances {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* Stage 94: Credits, Astory Coins, Astory Stars */
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.wallet-balance--coins { color: var(--secondary); }
/* Stage 94: Astory Stars (dark gold keeps 4.5:1 on the subtle box) */
.wallet-balance--stars { color: #a16207; }
.wallet-stars { display: flex; flex-direction: column; align-items: center; }
.wallet-stars__btn { margin-top: var(--space-3); background: linear-gradient(135deg, #a16207, #ca8a04); color: #fff; justify-content: center; }
.wallet-stars__btn:hover { color: #fff; filter: brightness(1.05); }
@media (max-width: 720px) {
  .wallet-balances { grid-template-columns: 1fr; }
}
/* Stage 94: the top bar gained Rewards Centre (and My Wallet for admins); tighten it before the hamburger takes over */
@media (min-width: 769px) and (max-width: 1240px) {
  .nav-links { gap: 0; }
  .nav-links a { padding: var(--space-2) var(--space-2); }
}
.wallet-extra {
  margin-top: 8px;
  color: #16a34a;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.wallet-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }
/* Narrow panel: balances stacked, slightly smaller figures */
.wallet-card--panel { padding: var(--space-5); }
.wallet-card--panel .wallet-balances { grid-template-columns: 1fr; gap: var(--space-3); margin-bottom: var(--space-4); }
.wallet-card--panel .wallet-balance { font-size: var(--text-2xl); }
.wallet-card--panel .wallet-card__icon { width: 20px; height: 20px; margin-right: 6px; }
.wallet-card--panel .promo-tooltip-wrap .promo-tooltip { white-space: normal; width: 200px; }
/* Stage 96: MyWallet.php is back to the Stage 94 layout (buttons in the row under the boxes). "Obtain Astory Stars"
   (students and admins) is the third button of that row, white with the Astory Stars gold. */
.wallet-obtain-btn { flex: 1; min-width: 160px; justify-content: center; background: #fff; color: #a16207; border: 1px solid #e7c873; box-shadow: none; }
.wallet-obtain-btn:hover { background: #fffbeb; color: #854d0e; }

/* ---- Stage 95: Current Study Streak (MemberHome.php Profile card; Stage 96 removed the hint line) ---- */
.study-streak__label { margin-top: var(--space-4); }
/* Stage 96: the card is titled with the member's full name and has two buttons; wrap on narrow screens */
.profile-card__head { flex-wrap: wrap; gap: var(--space-3); }
.profile-card__head h2 { min-width: 0; overflow-wrap: anywhere; }

/* ---- Stage 95: friend referrals (MyReferrals.php, HowToObtainAstoryStars.php, reg.php, SignupCourse.php) ---- */
.hint-inline { font-weight: 400; color: var(--text-muted); font-size: var(--text-sm); }
.referral-locked__box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid #e7c873;
  border-radius: var(--radius-lg);
  background: #fffbeb;
}
.referral-link { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; margin-top: var(--space-3); }
.referral-link input { flex: 1 1 280px; min-width: 0; font-family: var(--font-mono, monospace); font-size: var(--text-sm); }
.referral-link .btn { flex: none; }
.referral-help { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); margin-top: var(--space-6); }
.referral-help .card { margin: 0; }
@media (max-width: 860px) { .referral-help { grid-template-columns: 1fr; } }
.referral-steps, .referral-list { padding-left: 1.4em; margin: var(--space-3) 0; }
.referral-steps li, .referral-list li { margin-bottom: var(--space-2); line-height: 1.55; }
.stars-howto { margin-bottom: var(--space-6); }
.stars-howto__intro { display: flex; gap: var(--space-5); align-items: flex-start; }
.stars-howto__intro h2 { margin-top: 0; }
.stars-howto__icon {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fef9c3;
  color: #a16207;
}
.stars-howto__icon svg { width: 30px; height: 30px; }
.stars-howto__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-4); }
.stars-howto__actions svg { width: 16px; height: 16px; }
@media (max-width: 560px) { .stars-howto__intro { flex-direction: column; } }

/* ---- Stage 88: MemberHome Announcements card (replaces the Wallet card beside Profile) ---- */
.dash-anno { border: 2px solid var(--warning); } /* same orange as the AnnoDetails.php card (.section-card.is-warning) */
.dash-anno__head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-3); }
.dash-anno__head h2 { margin: 0; }
.dash-anno__icon { width: 24px; height: 24px; vertical-align: middle; margin-right: 8px; }
/* Titles list: the MyInbox.php rows (.inbox-list / .inbox-item), as links instead of <details> */
.dash-anno__list { list-style: none; margin: 0; padding: 0; }
.dash-anno__item > a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: inherit;
  text-decoration: none;
}
.dash-anno__item > a:hover { background: var(--primary-lighter); }
.dash-anno__item > a:focus-visible { outline: 3px solid var(--primary-light); outline-offset: -3px; }
@media (max-width: 768px) {
  .dash-anno__item > a { flex-wrap: wrap; }
}
.dash-anno__empty { margin: 0; padding: var(--space-4); text-align: center; color: var(--text-muted); background: var(--bg-subtle); border-radius: var(--radius-lg); }

/* Stage 89: admin-only shortcut strip under the breadcrumb (sys/AdminShortcutView.php) */
.admin-shortcuts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-4); padding: var(--space-2) var(--space-3); border: 1px dashed var(--border); border-radius: var(--radius-lg); background: var(--bg-subtle); }
.admin-shortcuts .btn svg { width: 14px; height: 14px; }
/* Stage 93: hidden IDs in the admin strip and on list rows (one click selects a value) */
.admin-ids { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); }
.admin-id { display: inline-flex; align-items: baseline; gap: 4px; font-size: var(--text-sm); color: var(--text-secondary); }
.admin-id__label { font-weight: 600; }
.admin-id__value { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--text-main); user-select: all; }
.admin-shortcuts__links { display: inline-flex; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }
.admin-id-tag { display: inline-flex; align-items: baseline; gap: 3px; margin-left: var(--space-1); padding: 0 6px; border: 1px dashed var(--border); border-radius: var(--radius-full, 999px); font-size: var(--text-xs, 0.75rem); font-weight: 500; color: var(--text-secondary); background: var(--bg-subtle); white-space: nowrap; }

/* =============================================================================
   Stage 98: legal documents, date of birth, under-18 display boxes, wider sign-up
   ============================================================================= */

/* Date of birth: red box + red message (js/legal-birthday.js and the server both set .is-invalid) */
.form-field input.is-invalid,
.form-field input[aria-invalid="true"] {
  border-color: var(--danger);
  background-color: var(--danger-light);
}
.form-field input.is-invalid:focus,
.form-field input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}
.form-field .field-error { line-height: 1.45; }

/* Fragment content (TermsAndConditions.php, PrivacyPolicy.php and the display boxes) */
.legal-doc { line-height: 1.6; }
.legal-doc h2 { font-size: var(--text-lg); margin: var(--space-6) 0 var(--space-2); }
.legal-doc h3 { font-size: var(--text-base); margin: var(--space-4) 0 var(--space-2); }
.legal-doc h2:first-child,
.legal-doc h3:first-child { margin-top: 0; }
.legal-doc p,
.legal-doc ul,
.legal-doc ol { margin: 0 0 var(--space-3); }
.legal-doc ul,
.legal-doc ol { padding-left: 1.5em; }
.legal-doc table { width: 100%; border-collapse: collapse; margin-bottom: var(--space-3); }
.legal-doc th,
.legal-doc td { border: 1px solid var(--border); padding: var(--space-2); text-align: left; vertical-align: top; }
.legal-doc--page { max-width: 900px; margin: 0 auto; }
.legal-version { margin: var(--space-1) 0 0; color: var(--text-muted); }
.legal-draft-notice {
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--danger-light);
  color: var(--danger-dark);
}

/* TermsAndConditions.php without ?doc: one card per account type */
.legal-choice-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}
.legal-choice { display: flex; flex-direction: column; gap: var(--space-2); text-decoration: none; color: inherit; }
.legal-choice:hover { border-color: var(--primary); }
.legal-choice__title { font-weight: 600; color: var(--primary); }

/* reg.php / SignupCourse.php: under-18 display boxes (5 lines each; scrolling optional) */
.legal-inline { margin-bottom: var(--space-4); }
.legal-inline__intro { margin: 0 0 var(--space-3); }
.legal-inline__item + .legal-inline__item { margin-top: var(--space-3); }
.legal-inline__title { font-size: var(--text-sm); font-weight: 600; margin: 0 0 var(--space-1); }
.legal-preview {
  font-size: var(--text-sm);
  line-height: 1.6;
  max-height: calc(5 * 1.6em + 2 * var(--space-3) + 2px);
  overflow-y: auto;
  padding: var(--space-3);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: left;
}
.legal-preview h2,
.legal-preview h3 { font-size: var(--text-sm); margin: var(--space-2) 0 var(--space-1); }
.legal-preview p,
.legal-preview ul,
.legal-preview ol { margin-bottom: var(--space-2); }
.legal-preview .legal-draft-notice { padding: var(--space-2) var(--space-3); margin-bottom: var(--space-2); }
.legal-preview:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* SignupCourse.php: wider sign-up column (the page also uses the wide container, sys/header.php) */
.details-layout.is-signup { grid-template-columns: minmax(0, 1.3fr) minmax(420px, 1fr); }
@media (max-width: 900px) {
  .details-layout.is-signup { grid-template-columns: 1fr; }
}

@media print {
  .legal-doc--page { max-width: none; border: 0; box-shadow: none; padding: 0; }
}

/* ---- Stage 99: CancelEnrolment.php ------------------------------------------
   The instant credit refund is deliberately the more prominent choice (owner request):
   large green-accented card, badges, benefit ticks and a big filled button; the manual refund
   request is a plain, quieter card with an outline button and the 20-business-day warning. */
.cancel-summary dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-4) 0;
}
.cancel-summary dd { margin: 0; font-weight: 700; text-align: right; }
.cancel-option__form { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; }
.cancel-option__form textarea { width: 100%; }
.cancel-option__form .btn { align-self: flex-start; }
.cancel-done__title { margin-top: 0; color: #047857; }
.cancel-done__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); }

/* ---- Stage 99: Cloudflare Turnstile human check on public forms (sys/HumanCheckCommon.php) ---- */
.human-check-widget { width: 100%; flex-basis: 100%; margin: 0 0 var(--space-4); }
.human-check-widget .cf-turnstile { min-height: 65px; }
.form-actions .human-check-widget { margin-bottom: 0; }
.human-check-wait { margin: var(--space-2) 0 0; color: var(--danger-dark); font-weight: 600; }

/* ---- Stage 99: AdminTransaction totals strip + AdminPromoCredits ---------------------------- */
.txn-totals__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.txn-totals__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-4); }
.txn-totals__num { font-size: var(--text-2xl); font-weight: 800; color: var(--text-main); }
.txn-totals__num.is-in { color: #047857; }
.txn-totals__num.is-out { color: #b91c1c; }
.promo-admin__balances { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); margin: var(--space-4) 0; }
.promo-admin__balance { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); background: var(--bg-subtle); }
.promo-admin__balance .value { font-size: var(--text-2xl); font-weight: 800; color: var(--text-main); }
.promo-admin__form { display: grid; grid-template-columns: minmax(160px, 220px) minmax(120px, 180px) minmax(0, 1fr) auto; gap: var(--space-3); align-items: end; }
.promo-admin__form label { margin-bottom: var(--space-1); }
.promo-admin__form input, .promo-admin__form select { margin: 0; }
@media (max-width: 900px) { .promo-admin__form { grid-template-columns: 1fr; } }
.promo-admin__warn { margin-top: var(--space-3); }
