:root {
  /* UWorld-Style Professional Color Palette */
  /* Primary Navy Blues - adjusted for better Mac display */
  --color-primary-50: #f0f9ff;
  --color-primary-100: #e0f2fe;
  --color-primary-200: #bae6fd;
  --color-primary-300: #7dd3fc;
  --color-primary-400: #38bdf8;
  --color-primary-500: #3182ce;
  --color-primary-600: #2563eb;
  --color-primary-700: #1e40af;
  --color-primary-800: #1e3a8a;
  --color-primary-900: #1e293b;

  /* Success (Medical Green) - improved contrast */
  --color-success-50: #f0fdf4;
  --color-success-100: #dcfce7;
  --color-success-200: #bbf7d0;
  --color-success-500: #22c55e;
  --color-success-600: #16a34a;
  --color-success-700: #15803d;

  /* Error (Medical Red) - improved contrast */
  --color-error-50: #fef2f2;
  --color-error-100: #fee2e2;
  --color-error-200: #fca5a5;
  --color-error-500: #ef4444;
  --color-error-600: #dc2626;
  --color-error-700: #b91c1c;

  /* Neutrals (Soft Grays) - Light Mode - refined for Mac Retina */
  --color-neutral-50: #f9fafb;
  --color-neutral-100: #f3f4f6;
  --color-neutral-200: #e5e7eb;
  --color-neutral-300: #d1d5db;
  --color-neutral-400: #9ca3af;
  --color-neutral-500: #6b7280;
  --color-neutral-600: #4b5563;
  --color-neutral-700: #374151;
  --color-neutral-800: #1f2937;
  --color-neutral-900: #111827;

  /* Semantic Aliases */
  --color-primary: var(--color-primary-600);
  --color-primary-light: var(--color-primary-500);
  --color-background: var(--color-neutral-50);
  --color-text: var(--color-neutral-700);
  --color-text-muted: var(--color-neutral-500);
  --color-border: var(--color-neutral-200);
  --color-border-dark: var(--color-neutral-300);

  /* Typography */
  --font-vignette: Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", sans-serif;
  --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", sans-serif;
  --font-mono: "SF Mono", Consolas, Monaco, monospace;

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

  /* Line Heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;
  --leading-vignette: 1.8;

  /* Spacing (8px system) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  /* Shadows (Subtle) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.12);
  --shadow-soft: var(--shadow-md);

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;
}

* {
  box-sizing: border-box;
}

html {
  /* Align native form controls with theme */
  color-scheme: light dark;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background-color: var(--color-background);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;

  /* iOS-specific smooth scrolling and momentum */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;

  /* Prevent browser pull-to-refresh */
  overscroll-behavior-y: contain;

  /* Enhanced tap highlighting for iOS */
  -webkit-tap-highlight-color: rgba(43, 108, 176, 0.1);

  /* Disable callout on iOS for better UX */
  -webkit-touch-callout: none;

  /* Prevent font size changes on orientation change */
  -webkit-text-size-adjust: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

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

.container {
  width: min(1100px, 90vw);
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: #ffffff;
  box-shadow: 0 1px 12px rgba(15, 23, 42, 0.08);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}

.logo {
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--color-primary);
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  padding: 0;
  margin: 0;
}

.nav-toggle {
  display: none;
}

.hero {
  padding: 6rem 0 4rem;
  background: radial-gradient(circle at top left, rgba(49, 130, 206, 0.08), rgba(44, 82, 130, 0.02));
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1.1rem;
  color: var(--color-text-muted);
  max-width: 55ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-lg);
  background-color: var(--color-primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.button:hover,
.button:focus {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(43, 108, 176, 0.2);
}

.button-secondary {
  background-color: #ffffff;
  color: var(--color-primary);
  border: 1px solid var(--color-border-dark);
  box-shadow: none;
}

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

.section {
  padding: 4rem 0;
}

.section-header h2 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  margin-bottom: 0.5rem;
}

.section-header p {
  margin: 0;
  color: var(--color-text-muted);
}

.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 2rem;
}

.card {
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  background-color: #ffffff;
  box-shadow: var(--shadow-soft);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
}

.filters input,
.filters select {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font: inherit;
  min-width: 260px;
}

.question-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.question-card header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  background-color: var(--color-primary-100);
  color: var(--color-primary-700);
}

.badge--difficulty {
  background-color: var(--color-neutral-200);
  color: var(--color-neutral-700);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-actions a {
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-weight: 600;
  color: var(--color-primary);
  background-color: var(--color-primary-50);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.card-actions a:hover,
.card-actions a:focus {
  background-color: var(--color-primary-100);
  transform: translateY(-1px);
}

.download-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.download-card .card-actions {
  margin-top: auto;
}

.site-footer {
  padding: 2rem 0;
  background-color: var(--color-neutral-900);
  color: var(--color-neutral-100);
  text-align: center;
  font-size: var(--text-sm);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 720px) {
  .site-header .container {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: var(--radius-md);
    background-color: var(--color-primary-50);
    color: var(--color-primary);
    font-weight: 600;
    cursor: pointer;
  }

  .nav-links {
    flex-direction: column;
    width: 100%;
    display: none;
    padding-bottom: 1rem;
  }

  .nav-links[aria-expanded="true"] {
    display: flex;
  }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

/* Dark mode manual override class - refined for Mac Retina */
html.dark-mode,
body.dark-mode {
  /* Dark mode color overrides */
  --color-neutral-50: #0f1419;
  --color-neutral-100: #1f2937;
  --color-neutral-200: #374151;
  --color-neutral-300: #4b5563;
  --color-neutral-400: #6b7280;
  --color-neutral-500: #9ca3af;
  --color-neutral-600: #d1d5db;
  --color-neutral-700: #e5e7eb;
  --color-neutral-800: #f3f4f6;
  --color-neutral-900: #f9fafb;

  --color-background: #0f1419;
  --color-text: #e5e7eb;
  --color-text-muted: #9ca3af;
  --color-border: #374151;
  --color-border-dark: #4b5563;

  --color-primary: var(--color-primary-400);
  --color-primary-light: var(--color-primary-300);
}

body.dark-mode {
  background-color: #0f1419;
  color: #e5e7eb;
}

body.dark-mode .site-header,
html.dark-mode .site-header {
  background-color: #1f2937;
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
}

body.dark-mode .card,
html.dark-mode .card {
  background-color: #1f2937;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode .button,
html.dark-mode .button {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-mode .button:hover,
body.dark-mode .button:focus,
html.dark-mode .button:hover,
html.dark-mode .button:focus {
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.4);
}

body.dark-mode .button-secondary,
html.dark-mode .button-secondary {
  background-color: #1f2937;
  color: var(--color-primary-300);
  border-color: #374151;
}

body.dark-mode .button-secondary:hover,
html.dark-mode .button-secondary:hover {
  background: #374151;
  border-color: #4b5563;
}

body.dark-mode .filters input,
body.dark-mode .filters select,
html.dark-mode .filters input,
html.dark-mode .filters select {
  background-color: #1f2937;
  border-color: #374151;
  color: #e5e7eb;
}

body.dark-mode .card-actions a,
html.dark-mode .card-actions a {
  background-color: #1f2937;
  border-color: #374151;
  color: var(--color-primary-300);
}

body.dark-mode .card-actions a:hover,
body.dark-mode .card-actions a:focus,
html.dark-mode .card-actions a:hover,
html.dark-mode .card-actions a:focus {
  background-color: #374151;
}

/* Confetti Animation */
.confetti {
  position: fixed;
  top: -10px;
  width: 10px;
  height: 10px;
  background-color: #3182ce;
  opacity: 0.8;
  border-radius: 50%;
  animation: confetti-fall linear forwards;
  pointer-events: none;
  z-index: 10000;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}
