/* ============================================================
   lets.learn.cyber - Design System
   Dark SaaS learning platform aesthetic
   ============================================================ */

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

:root {
  --bg:       #0f1117;
  --surface:  #161920;
  --surface2: #1e2330;
  --border:   #2a2f3d;
  --border-hover: #00e5b0;
  --accent:   #00e5b0;
  --accent-dim: rgba(0, 229, 176, 0.12);
  --accent-dim2: rgba(0, 229, 176, 0.06);
  --text:     #e8eaf0;
  --muted:    #9aa3b5;
  --muted2:   #5a6170;
  --danger:   #ff4d6d;
  --amber:    #fbbf24;
  --green:    #22c55e;
  --blue:     #60a5fa;
  --radius:   12px;
  --radius-sm: 6px;
  --shadow:   0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.6);
  --nav-h:    64px;
  --max-w:    1100px;
}

/* --- OpenDyslexic (accessibility font, self-hosted) --------- */
@font-face {
  font-family: 'OpenDyslexic';
  src: url('/fonts/OpenDyslexic-Regular.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'OpenDyslexic';
  src: url('/fonts/OpenDyslexic-Bold.otf') format('opentype');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Outfit', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* --- Typography -------------------------------------------- */
h1, h2, h3, h4 {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }

p { color: var(--muted); line-height: 1.75; }

code, pre {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.875em;
}

/* --- Layout Utilities -------------------------------------- */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 2rem;
}

.section {
  padding: 4rem 0;
}

.section-sm {
  padding: 2.5rem 0;
}

/* --- Skip Link --------------------------------------------- */
.skip-link {
  position: absolute;
  top: -9999px;
  left: 1rem;
  background: var(--accent);
  color: #0f1117;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  z-index: 9999;
}
.skip-link:focus { top: 1rem; }

/* --- Beta banner ------------------------------------------- */
.beta-banner {
  background: rgba(59, 130, 246, 0.12);
  border-bottom: 1px solid rgba(59, 130, 246, 0.25);
  font-size: 0.8rem;
  color: var(--text);
  margin-top: var(--nav-h);
}
.beta-banner-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
}
.beta-banner strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 3px;
  padding: 0.1rem 0.45rem;
  color: #60a5fa;
}
.beta-banner-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  flex-shrink: 0;
}
.beta-banner-close:hover {
  color: var(--text);
}

/* --- Navigation -------------------------------------------- */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 2rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.nav-logo {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.nav-logo:hover { text-decoration: none; color: var(--text); }
.nav-logo .accent { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  flex: 1;
  justify-content: flex-end;
}

.nav-links a {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}
.nav-links a:hover { color: var(--text); background: var(--surface2); }
.nav-links a.active { color: var(--accent); text-decoration: none; }

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-username {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}

.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  background: none;
  cursor: pointer;
}
.nav-cta:hover {
  background: var(--accent);
  color: #0f1117;
  text-decoration: none;
}

/* hamburger */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  flex-direction: column;
  gap: 5px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* --- Buttons ----------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #0f1117;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: #00ccaa;
  border-color: #00ccaa;
  box-shadow: 0 0 24px rgba(0, 229, 176, 0.3);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text); background: var(--surface2); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.85rem 2rem;
  font-size: 1rem;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover {
  border-color: var(--muted2);
  color: var(--text);
}

/* Avatar upload section on edit profile */
.avatar-edit-section {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  margin-bottom: 1.5rem;
}
.avatar-edit-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.avatar-edit-controls {
  flex: 1;
  min-width: 0;
}
.avatar-edit-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.avatar-edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.avatar-upload-label {
  cursor: pointer;
}
.avatar-status {
  font-size: 0.78rem;
  margin-top: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
}
.avatar-status.success { color: #22c55e; }
.avatar-status.error   { color: #ef4444; }

.btn-full { width: 100%; }

.btn:disabled, .btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* --- Hero -------------------------------------------------- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(var(--nav-h) + 4rem) 2rem 5rem;
  position: relative;
  overflow: hidden;
}

/* subtle grid background */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 229, 176, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 176, 0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
}

/* radial glow behind hero text */
.hero::after {
  content: '';
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(0, 229, 176, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 780px;
  width: 100%;
}

.hero-eyebrow {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1.5rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--accent-dim);
  border-radius: 100px;
  background: var(--accent-dim2);
}

.hero-title {
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
}
.hero-title .accent { color: var(--accent); }

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 540px;
  margin: 0 auto 2.5rem;
  line-height: 1.7;
}

.hero-cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Stats Row --------------------------------------------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 4rem;
}

.stat-item {
  background: var(--surface);
  padding: 2rem;
  text-align: center;
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.4rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.stat-note {
  font-size: 0.75rem;
  color: var(--muted2);
}

/* --- Section Labels ---------------------------------------- */
.section-label {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.75rem;
}

.section-heading {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: 0.75rem;
  color: var(--text);
}

.section-sub {
  font-size: 1rem;
  color: var(--muted);
  max-width: 520px;
  margin-bottom: 3rem;
}

/* --- Cards ------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
  cursor: default;
  display: flex;
  flex-direction: column;
}

.card:hover {
  border-color: rgba(0, 229, 176, 0.35);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 229, 176, 0.1);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  color: var(--accent);
}
.card-icon svg {
  width: 22px;
  height: 22px;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-coming-soon {
  background: rgba(251, 191, 36, 0.12);
  color: var(--amber);
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.badge-beginner {
  background: rgba(34, 197, 94, 0.1);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-intermediate {
  background: rgba(96, 165, 250, 0.1);
  color: var(--blue);
  border: 1px solid rgba(96, 165, 250, 0.2);
}

.badge-advanced {
  background: rgba(255, 77, 109, 0.1);
  color: var(--danger);
  border: 1px solid rgba(255, 77, 109, 0.2);
}

.card-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.card-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.card-meta-item {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted2);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 1rem;
}
.card-footer-areas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* --- Page Header ------------------------------------------- */
.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: calc(var(--nav-h) + 2rem) 0 2rem;
}

.page-header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
}

.page-header-sub {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

/* --- Login Page -------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--nav-h) + 2rem) 2rem 4rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.login-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 2rem;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--muted2);
  font-size: 0.75rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-provider-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 0.75rem;
}
.login-provider-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  text-decoration: none;
  background: rgba(0, 229, 176, 0.05);
}
.login-provider-btn:last-of-type { margin-bottom: 0; }

.login-provider-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.login-note {
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: var(--muted2);
  text-align: center;
  line-height: 1.6;
}

/* --- Dashboard -------------------------------------------- */
.dashboard-page {
  padding-top: var(--nav-h);
  min-height: 100vh;
}

.dashboard-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 2.5rem 0;
}

.dashboard-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.dashboard-welcome {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  flex-shrink: 0;
}

.dashboard-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.7rem;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 2rem;
}

.dashboard-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.dashboard-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.35rem;
}

.dashboard-stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 2rem;
}

.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.dashboard-card-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

.dashboard-empty {
  font-size: 0.875rem;
  color: var(--muted2);
  line-height: 1.6;
}

/* --- CTA Section ------------------------------------------ */
.cta-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4rem 0;
  text-align: center;
}

.cta-section h2 {
  margin-bottom: 0.75rem;
}

.cta-section p {
  margin-bottom: 2rem;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

/* --- Footer ----------------------------------------------- */
.site-footer {
  padding: 2rem;
  text-align: center;
  border-top: 1px solid var(--border);
}

.site-footer p {
  font-size: 0.8rem;
  color: var(--muted2);
}

.site-footer a {
  color: var(--muted);
}
.site-footer a:hover { color: var(--accent); }

/* --- Placeholder / Empty States --------------------------- */
.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted2);
  font-size: 0.875rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* --- Focus Visible ---------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
:focus:not(:focus-visible) { outline: none; }

/* --- Reduced Motion --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Responsive ------------------------------------------- */
@media (max-width: 768px) {
  .stats-row { grid-template-columns: 1fr; }
  .dashboard-stats { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }

  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1rem;
    gap: 0.25rem;
    z-index: 999;
    overflow-y: auto;
  }
  .nav-links.open { display: flex; }
  .nav-links a { width: 100%; padding: 0.6rem 1rem; }

  .nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--nav-h);
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
  }
  .nav-backdrop.open { display: block; }

  .nav-toggle { display: flex; }

  .hero { padding-top: calc(var(--nav-h) + 2rem); }
}

@media (max-width: 480px) {
  .container { padding: 0 1rem; }
  .hero-cta { flex-direction: column; align-items: center; }
  .login-card { padding: 1.75rem; }
}

/* --- Section alternating background ----------------------- */
.section-alt {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* --- Nav Dropdown ----------------------------------------- */
.nav-end {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  list-style: none;
  transition: background 0.15s;
  border: 1px solid var(--border);
  background: transparent;
}
.nav-dropdown-trigger::-webkit-details-marker { display: none; }
.nav-dropdown-trigger::marker { display: none; }
.nav-dropdown-trigger:hover { background: var(--surface2); }

.nav-chevron {
  color: var(--muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.nav-dropdown[open] .nav-chevron {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.375rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.nav-dropdown-item:hover {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}
.nav-dropdown-item svg {
  flex-shrink: 0;
  opacity: 0.6;
}

.nav-dropdown-signout { color: var(--danger); }
.nav-dropdown-signout:hover { background: rgba(255, 77, 109, 0.08); color: var(--danger); }

.nav-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* Left-aligned dropdown (for nav-links dropdowns) */
.nav-dropdown-menu--left {
  right: auto;
  left: 0;
}

/* Nav-links inline dropdown trigger — matches other nav link styles, no border */
.nav-dropdown-trigger--link {
  border: none;
  padding: 0;
  font-size: inherit;
  color: var(--muted);
  font-family: inherit;
  font-weight: 400;
  background: transparent;
  border-radius: var(--radius-sm);
}
.nav-dropdown-trigger--link:hover {
  background: transparent;
  color: var(--text);
}
.nav-links .nav-dropdown {
  list-style: none;
}
.nav-dropdown-label {
  padding: 0.3rem 0.75rem 0.15rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted2);
  font-family: 'JetBrains Mono', monospace;
}

/* --- Prose (legal pages) ----------------------------------- */
.prose {
  color: var(--muted);
  line-height: 1.8;
  font-size: 0.95rem;
}
.prose p {
  margin-bottom: 1.25rem;
}
.prose h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
}
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.prose a:hover {
  opacity: 0.8;
}

/* --- Forms ------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.form-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.form-input,
.form-select,
.form-textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.9rem;
  width: 100%;
  transition: border-color 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

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

.form-hint {
  font-size: 0.75rem;
  color: var(--muted2);
}

.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  padding: 0.6rem 0.9rem;
  background: rgba(255, 77, 109, 0.08);
  border: 1px solid rgba(255, 77, 109, 0.25);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

/* --- Admin Layout ------------------------------------------ */
.admin-page {
  padding-top: var(--nav-h);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  flex: 1;
  align-items: start;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
  padding: 2rem;
  gap: 2rem;
}

.admin-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: sticky;
  top: calc(var(--nav-h) + 1.5rem);
}

.admin-sidebar-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0 0.5rem;
  margin-bottom: 0.75rem;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  font-weight: 500;
}

.admin-nav-link:hover {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

.admin-nav-link.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.admin-main {
  min-width: 0;
}

.admin-header {
  margin-bottom: 1.5rem;
}

.admin-header h1 {
  font-size: 1.6rem;
  margin-bottom: 0.25rem;
}

/* --- Admin Tables ------------------------------------------ */
.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.admin-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

.admin-table tr:hover td {
  background: var(--surface2);
}

/* --- Admin Stat Cards -------------------------------------- */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.admin-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.admin-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.3rem;
}

.admin-stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* --- Role Badge -------------------------------------------- */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* --- WorldSkills Tag --------------------------------------- */
.ws-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  background: rgba(234, 179, 8, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(234, 179, 8, 0.25);
}

.ws-tag-sections {
  opacity: 0.7;
  font-weight: 500;
}

/* --- Colour Swatch ----------------------------------------- */
.colour-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: inline-block;
  flex-shrink: 0;
}

/* --- Admin Search Form ------------------------------------- */
.admin-search-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.admin-search-form .form-input {
  max-width: 320px;
}

/* --- Small avatar ------------------------------------------ */
.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--accent);
  flex-shrink: 0;
  overflow: hidden;
}

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

/* --- Admin responsive -------------------------------------- */
@media (max-width: 768px) {
  .admin-layout {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
  .admin-sidebar {
    position: static;
  }
  .admin-stats {
    grid-template-columns: 1fr;
  }
  .admin-table-wrap {
    overflow-x: auto;
  }
}

/* --- Module Content (markdown render) ---------------------- */
.module-content h1 { font-size: 1.5rem; margin: 1.5rem 0 0.75rem; }
.module-content h2 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; color: var(--text); }
.module-content h3 { font-size: 1.05rem; margin: 1.25rem 0 0.5rem; color: var(--text); }
.module-content pre { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; overflow-x: auto; margin: 1rem 0; }
.module-content code { font-family: 'JetBrains Mono', monospace; font-size: 0.85em; }
.module-content p code { background: var(--surface2); padding: 0.15em 0.4em; border-radius: 3px; }
.module-content ul, .module-content ol { padding-left: 1.5rem; margin: 0.75rem 0; }
.module-content li { margin-bottom: 0.35rem; color: var(--muted); }
.module-content blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; margin: 1rem 0; color: var(--muted); }
.module-content img { max-width: 100%; border-radius: var(--radius-sm); }
.module-content a { color: var(--accent); text-decoration: underline; }
.module-content hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* --- Filter buttons (pagination, admin tabs) --------------- */
.filter-btn {
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.filter-btn:hover, .filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim2);
}

/* --- Filter toolbar (modules index) ----------------------- */
.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
}
.filter-control {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.filter-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.35rem 1.75rem 0.35rem 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235a6170' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
}
.filter-select:hover {
  border-color: var(--muted2);
}
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  color: var(--accent);
}
/* Highlight when a non-default value is selected */
.filter-select.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- View toggle buttons ----------------------------------- */
.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted2);
  background: transparent;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  text-decoration: none;
}
.view-toggle-btn:hover {
  border-color: var(--muted2);
  color: var(--muted);
  text-decoration: none;
}
.view-toggle-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim2);
}

/* --- Result count ------------------------------------------ */
.result-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted2);
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

/* --- Area Tag ---------------------------------------------- */
.area-tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  padding: 0.2rem 0.3rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted2);
  white-space: nowrap;
}
.area-tag-icon--text {
  font-size: 0.6rem;
  line-height: 1;
}
.area-tag-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.7;
}
.area-tag-icon svg {
  width: 12px;
  height: 12px;
}

/* --- Module sections (grouped by path/track) --------------- */
.module-section {
  margin-bottom: 3rem;
}
.module-section-path {
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.module-track-group {
  margin-bottom: 2rem;
}
.module-track-heading {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
}
.module-track-heading a {
  color: inherit;
  text-decoration: none;
}
.module-track-heading a:hover {
  color: var(--accent);
}

/* --- Module list view -------------------------------------- */
.module-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.module-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.module-list-row:last-child { border-bottom: none; }
.module-list-row:hover { background: var(--surface2); }
.module-list-main {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 1;
}
.module-list-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.module-list-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.module-list-desc {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
}
.module-list-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.module-list-areas {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .module-list-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
  }
  .module-list-meta {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .module-list-desc { max-width: 100%; }
}

/* --- Stream accordion -------------------------------------- */
.track-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}
.track-section-header {
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.track-section-header:hover { background: var(--surface2); }
.track-section-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.track-section-body {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.module-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  gap: 0.75rem;
}
.module-list-item:hover { border-color: var(--border-hover); }
.module-list-item a { color: var(--text); font-size: 0.875rem; font-weight: 500; }
.module-list-item a:hover { color: var(--accent); text-decoration: none; }
.completion-check {
  color: var(--green);
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

/* --- Dashboard stat cards (new 4-up layout) ---------------- */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
.dash-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.25rem;
}
.dash-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.25rem;
}
.dash-stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* --- Dashboard two-column layout --------------------------- */
.dash-cols {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

/* --- XP event list ----------------------------------------- */
.xp-event-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.xp-event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.xp-event-item:last-child { border-bottom: none; }
.xp-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

/* --- Leaderboard ------------------------------------------- */
.leaderboard-row-gold td { background: rgba(245, 158, 11, 0.06); }
.leaderboard-row-silver td { background: rgba(148, 163, 184, 0.06); }
.leaderboard-row-bronze td { background: rgba(180, 120, 60, 0.06); }
.leaderboard-row-me td { background: rgba(99, 102, 241, 0.08); }
.rank-medal { font-size: 1rem; }

/* --- Badge (circuit board) --------------------------------- */
.badge-outer {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}
.badge-outer--lg { width: 72px; }
.badge-outer--md { width: 52px; }
.badge-outer--sm { width: 36px; }
.badge-circuit { display: block; }
.badge-icon-inner {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  line-height: 1;
}
.badge-outer--lg .badge-icon-inner { width: 72px; height: 72px; }
.badge-outer--md .badge-icon-inner { width: 52px; height: 52px; }
.badge-outer--sm .badge-icon-inner { width: 36px; height: 36px; }
.badge-icon-inner svg { width: 42%; height: 42%; }
.badge-name {
  font-size: 0.65rem;
  color: var(--muted);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  max-width: 80px;
  line-height: 1.2;
}
.badge-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

/* --- Profile lower grid ------------------------------------ */
.profile-lower {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
}


/* In dark mode: show moon, hide sun */
.theme-icon--sun { display: none; }
.theme-icon--moon { display: block; }

/* In light mode: show sun, hide moon */
body.a11y-theme-light .theme-icon--sun { display: block; }
body.a11y-theme-light .theme-icon--moon { display: none; }

/* ── Accessibility: font ─────────────────────────────── */
body.a11y-font-opendyslexic,
body.a11y-font-opendyslexic * {
  font-family: 'OpenDyslexic', sans-serif !important;
}

/* ── Accessibility: spacing ──────────────────────────── */
body.a11y-spacing-relaxed {
  --a11y-line-height: 1.8;
  --a11y-letter-spacing: 0.04em;
  --a11y-word-spacing: 0.1em;
}

body.a11y-spacing-spacious {
  --a11y-line-height: 2.2;
  --a11y-letter-spacing: 0.08em;
  --a11y-word-spacing: 0.16em;
}

body.a11y-spacing-relaxed p,
body.a11y-spacing-relaxed li,
body.a11y-spacing-relaxed .module-content,
body.a11y-spacing-spacious p,
body.a11y-spacing-spacious li,
body.a11y-spacing-spacious .module-content {
  line-height: var(--a11y-line-height);
  letter-spacing: var(--a11y-letter-spacing);
  word-spacing: var(--a11y-word-spacing);
}

/* ── Accessibility: light theme ──────────────────────── */
body.a11y-theme-light {
  --bg:        #fdf6e3;
  --surface:   #f3ead9;
  --surface2:  #e9dfcc;
  --border:    #a89a82;
  --text:      #2c2416;
  --muted:     #6b5e4e;
  --muted2:    #6d6050;
  --accent:    #0a7a5e;
}

/* Invert code blocks in light theme for readability */
body.a11y-theme-light pre,
body.a11y-theme-light code,
body.a11y-theme-light .code-block {
  background: #ddd3c1;
  color: #2c2416;
}

/* Nav dropdown */
body.a11y-theme-light .nav-dropdown-menu {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

/* Cards */
body.a11y-theme-light .card {
  border-color: var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Badge circuit board background */
body.a11y-theme-light .badge-bg {
  fill: #e8dfd0;
}

/* Role badges / difficulty pills */
body.a11y-theme-light .role-badge {
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Form inputs */
body.a11y-theme-light input,
body.a11y-theme-light textarea,
body.a11y-theme-light select {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

/* Buttons with dark text on accent background */
body.a11y-theme-light .btn-primary {
  color: #fdf6e3;
}
body.a11y-theme-light .nav-cta:hover {
  color: #fdf6e3;
}
body.a11y-theme-light .skip-link {
  color: #fdf6e3;
}

/* Footer */
body.a11y-theme-light .site-footer {
  border-top-color: var(--border);
}

/* Accent dim needs adjustment for light bg */
body.a11y-theme-light {
  --accent-dim: rgba(10, 122, 94, 0.1);
  --accent-dim2: rgba(10, 122, 94, 0.05);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.12);
  --green: #16a34a;
  --danger: #dc2626;
}

/* ── Accessibility: settings controls ────────────────── */
.a11y-option-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.a11y-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}

.a11y-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(0, 229, 176, 0.06);
}

.a11y-option input[type="radio"] {
  accent-color: var(--accent);
}

.a11y-spacing-preview {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  font-size: 0.9rem;
  color: var(--muted);
  transition: line-height 0.2s, letter-spacing 0.2s;
}

.a11y-spacing-preview.a11y-spacing-relaxed {
  line-height: 1.8;
  letter-spacing: 0.04em;
  word-spacing: 0.1em;
}

.a11y-spacing-preview.a11y-spacing-spacious {
  line-height: 2.2;
  letter-spacing: 0.08em;
  word-spacing: 0.16em;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
  margin-bottom: 0.5rem;
}

.theme-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* --- Split-Screen Auth Layout ------------------------------ */
.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  padding-top: var(--nav-h);
}

.auth-marketing {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem 3rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.auth-marketing::before {
  content: '';
  position: absolute;
  bottom: -80px;
  right: -80px;
  width: 300px;
  height: 300px;
  border: 1px solid var(--border);
  border-radius: 50%;
  opacity: 0.3;
  pointer-events: none;
}

.auth-marketing::after {
  content: '';
  position: absolute;
  bottom: -40px;
  right: -40px;
  width: 200px;
  height: 200px;
  border: 1px solid var(--border);
  border-radius: 50%;
  opacity: 0.2;
  pointer-events: none;
}

.auth-brand {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 1.25rem;
}

.auth-headline {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 1rem;
}

.auth-tagline {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 2.5rem;
  max-width: 380px;
}

.auth-props {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.auth-prop {
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}

.auth-prop:last-child {
  border-bottom: 1px solid var(--border);
}

.auth-prop-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.auth-prop-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}


.auth-form-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 3rem;
}

.auth-form-inner {
  width: 100%;
  max-width: 380px;
}

.auth-form-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  margin-bottom: 0.5rem;
}

.auth-form-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 0.5rem;
}

.auth-form-sub {
  font-size: 0.875rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 2rem;
}

.auth-providers {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.auth-switch {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  margin-top: 1.5rem;
}

.auth-switch a {
  color: var(--accent);
  font-weight: 500;
}

/* --- Content Stats Bar ------------------------------------ */
.content-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2rem;
}

.content-stat {
  background: var(--surface);
  padding: 1.1rem 1.25rem;
  text-align: center;
}

.content-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.3rem;
}

.content-stat-value--green {
  color: var(--green);
}

.content-stat-value--muted {
  color: var(--muted);
}

.content-stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

/* --- Responsive additions ---------------------------------- */
@media (max-width: 768px) {
  .dash-stats { grid-template-columns: repeat(2, 1fr); }
  .dash-cols { grid-template-columns: 1fr; }
  .profile-lower { grid-template-columns: 1fr; }

  .auth-split {
    grid-template-columns: 1fr;
  }

  .auth-marketing {
    padding: 2.5rem 1.5rem 2rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .auth-marketing::before,
  .auth-marketing::after {
    display: none;
  }


  .auth-form-panel {
    padding: 2rem 1.5rem 3rem;
  }

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

@media (max-width: 480px) {
  .auth-marketing {
    padding: 2rem 1rem 1.5rem;
  }

  .auth-form-panel {
    padding: 1.5rem 1rem 2.5rem;
  }

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

/* ── Light theme: additional fixes ──────────────────── */
body.a11y-theme-light .module-list-item {
  border-color: var(--border);
}
body.a11y-theme-light .dashboard-card {
  border-color: var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
body.a11y-theme-light .admin-table th {
  background: var(--surface);
  color: var(--text);
}
body.a11y-theme-light .admin-table td {
  border-color: var(--border);
}
body.a11y-theme-light .filter-select,
body.a11y-theme-light .form-select {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
body.a11y-theme-light .btn-outline {
  border-color: var(--border);
  color: var(--text);
}
body.a11y-theme-light .btn-ghost {
  color: var(--muted);
}
body.a11y-theme-light .nav-dropdown-menu {
  background: var(--surface);
  border-color: var(--border);
}
body.a11y-theme-light .page-header {
  border-bottom-color: var(--border);
}
body.a11y-theme-light .completion-check {
  color: var(--green);
}
body.a11y-theme-light .xp-toast {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--text);
}
body.a11y-theme-light .question-card {
  background: var(--surface);
  border-color: var(--border);
}
body.a11y-theme-light .option-btn {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text);
}
body.a11y-theme-light .beta-banner {
  background: var(--surface);
  border-bottom-color: var(--border);
}
body.a11y-theme-light .content-stat {
  background: var(--surface);
}

/* ── Code block overflow fix (mobile) ──────────────── */
pre, .module-content pre {
  overflow-x: auto;
  max-width: 100%;
}
.module-content pre code {
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

/* ── Emulated Lab Terminal ──────────────────────────── */
.lab-terminal-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.lab-terminal {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: var(--radius);
  min-height: 420px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.lab-terminal-output {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #c9d1d9;
  white-space: pre-wrap;
  word-break: break-word;
}
.lab-terminal-input {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border-top: 1px solid #30363d;
  background: #161b22;
}
.lab-terminal-prompt {
  color: #3fb950;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  margin-right: 0.5rem;
  flex-shrink: 0;
  white-space: nowrap;
}
.lab-terminal-input input {
  background: transparent;
  border: none;
  color: #c9d1d9;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  flex: 1;
  outline: none;
  caret-color: #3fb950;
}
.lab-objectives {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  align-self: start;
  position: sticky;
  top: calc(var(--nav-h) + 1rem);
}
.lab-success {
  color: #3fb950;
  font-weight: 600;
}

@media (max-width: 768px) {
  .lab-terminal-layout {
    grid-template-columns: 1fr;
  }
  .lab-terminal {
    min-height: 300px;
  }
  .lab-objectives {
    position: static;
  }
}

/* Force dark terminal even in light theme */
body.a11y-theme-light .lab-terminal {
  background: #0d1117;
  border-color: #30363d;
  color: #c9d1d9;
}
body.a11y-theme-light .lab-terminal-input {
  background: #161b22;
  border-color: #30363d;
}
body.a11y-theme-light .lab-terminal-input input {
  color: #c9d1d9;
}

/* --- Reduced motion (accessibility) ----------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

