:root {
  /* ============ MODERN COLOR PALETTE ============ */
  /* Primary Colors - Blue (Professional & Trustworthy) */
  --primary: #3b82f6;
  --primary-light: #60a5fa;
  --primary-dark: #1e40af;
  --primary-darker: #1e3a8a;
  
  /* Secondary - Slate (Neutral & Professional) */
  --secondary: #64748b;
  --secondary-light: #94a3b8;
  --secondary-dark: #334155;
  
  /* Accent - Emerald (Growth & Success) */
  --accent: #10b981;
  --accent-light: #34d399;
  --accent-dark: #059669;
  
  /* Neutral Colors */
  --background: #f8fafc;
  --background-dark: #0f172a;
  --card-bg: #ffffff;
  --card-bg-dark: #1e293b;
  --surface: #f1f5f9;
  --surface-dark: #334155;
  --surface-hover: #e2e8f0;
  --surface-hover-dark: #475569;
  
  /* Text Colors */
  --text: #0f172a;
  --text-dark: #f1f5f9;
  --text-muted: #64748b;
  --text-muted-dark: #cbd5e1;
  --text-secondary: #475569;
  --text-secondary-dark: #94a3b8;
  
  /* Status Colors */
  --success: #10b981;
  --success-light: #d1fae5;
  --success-dark: #047857;
  
  --error: #ef4444;
  --error-light: #fee2e2;
  --error-dark: #b91c1c;
  
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --warning-dark: #b45309;
  
  --info: #3b82f6;
  --info-light: #dbeafe;
  --info-dark: #1e40af;
  
  /* Borders & Shadows */
  --border: #e2e8f0;
  --border-dark: #475569;
  --border-hover: #cbd5e1;
  --border-hover-dark: #64748b;
  
  --shadow-color: rgba(15, 23, 42, 0.08);
  --shadow-color-lg: rgba(15, 23, 42, 0.12);
  --shadow-color-dark: rgba(0, 0, 0, 0.3);

  /* ============ TYPOGRAPHY ============ */
  --font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-family-mono: 'Menlo', 'Monaco', 'Courier New', monospace;
  
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;

  /* Font sizes - Mobile first */
  --font-size: 16px;
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-base: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 30px;
  --font-size-4xl: 36px;
  
  /* Line heights */
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;
  --line-height-loose: 2;

  /* ============ SPACING ============ */
  --spacing-0: 0;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;
  --spacing-2xl: 32px;
  --spacing-3xl: 48px;
  --spacing-4xl: 64px;

  /* ============ BORDER & RADIUS ============ */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;
  --button-radius: 999px;

  /* Brand gradients */
  --brand-gradient-start: #7687ff;
  --brand-gradient-end: #ff6fa7;
  --brand-gradient-hover-start: #8da0ff;
  --brand-gradient-hover-end: #ff85b5;
  --brand-shadow: 0 18px 36px rgba(118, 135, 255, 0.32);

  /* ============ SHADOWS ============ */
  --shadow-none: none;
  --shadow-sm: 0 1px 2px 0 var(--shadow-color);
  --shadow: 0 1px 3px 0 var(--shadow-color), 0 1px 2px 0 rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -1px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 15px -3px var(--shadow-color), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 20px 25px -5px var(--shadow-color-lg), 0 10px 10px -5px rgba(15, 23, 42, 0.04);
  --shadow-2xl: 0 25px 50px -12px var(--shadow-color-lg);

  /* ============ GLASS MORPHISM ============ */
  --glass-bg: rgba(255, 255, 255, 0.95);
  --glass-bg-dark: rgba(30, 41, 59, 0.95);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-border-dark: rgba(148, 163, 184, 0.1);
  --glass-backdrop: blur(10px) saturate(100%);

  /* ============ ANIMATIONS ============ */
  --duration-75: 75ms;
  --duration-100: 100ms;
  --duration-150: 150ms;
  --duration-200: 200ms;
  --duration-300: 300ms;
  --duration-500: 500ms;
  --duration-700: 700ms;
  --duration-1000: 1000ms;
  
  --ease-linear: linear;
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* ============ Z-INDEX SCALE ============ */
  --z-hide: -1;
  --z-auto: auto;
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-notification: 1080;
  
  /* ============ TRANSITIONS ============ */
  --transition-colors: color var(--duration-200) var(--ease-out), background-color var(--duration-200) var(--ease-out), border-color var(--duration-200) var(--ease-out);
  --transition-all: all var(--duration-200) var(--ease-out);
  --transition-transform: transform var(--duration-200) var(--ease-out);

  /* ============ BACKGROUND IMAGE ============ */
  --background-image: none;

  /* ============ SAFE AREA INSETS ============ */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
}

/* ============ DARK MODE ============ */
@media (prefers-color-scheme: dark) {
  :root {
    --background: var(--background-dark);
    --card-bg: var(--card-bg-dark);
    --surface: var(--surface-dark);
    --surface-hover: var(--surface-hover-dark);
    --text: var(--text-dark);
    --text-muted: var(--text-muted-dark);
    --text-secondary: var(--text-secondary-dark);
    --border: var(--border-dark);
    --border-hover: var(--border-hover-dark);
  }
}

/* Dark mode toggle support */
body.dark-mode {
  --background: var(--background-dark);
  --card-bg: var(--card-bg-dark);
  --surface: var(--surface-dark);
  --surface-hover: var(--surface-hover-dark);
  --text: var(--text-dark);
  --text-muted: var(--text-muted-dark);
  --text-secondary: var(--text-secondary-dark);
  --border: var(--border-dark);
  --border-hover: var(--border-hover-dark);
}

body.light-mode {
  --background: #f8fafc;
  --card-bg: #ffffff;
  --surface: #f1f5f9;
  --surface-hover: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-secondary: #475569;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
}

/* ============ RESPONSIVE BREAKPOINTS ============ */
@media (min-width: 640px) {
  :root {
    --font-size: 17px;
  }
}

@media (min-width: 768px) {
  :root {
    --font-size: 18px;
  }
}

@media (min-width: 1024px) {
  :root {
    --font-size: 18px;
  }
}

@media (min-width: 1280px) {
  :root {
    --font-size: 20px;
  }
}

.card-study, .browse-card, .theme-section {
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  backdrop-filter: blur(8px) saturate(140%);
  background: rgba(255,255,255,0.15); 
  color: white; 
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size);
  background-color: var(--background);
  background-image: var(--background-image);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  background-attachment: fixed;
  color: var(--text);
  line-height: var(--line-height-normal);
  margin: 0;
  padding: 0;
  padding-left: var(--safe-area-left);
  padding-right: var(--safe-area-right);
  padding-bottom: var(--safe-area-bottom);
  min-height: 100dvh;
  transition: background-color var(--duration-300) var(--ease-out),
              color var(--duration-300) var(--ease-out);
  
  /* Typography improvements */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  
  /* Mobile optimizations */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior-y: none;
}

/* ============ INTRO LANDING ============ */
.intro-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0ea5e9 0%, #2563eb 45%, #0f172a 100%);
  color: #ffffff;
}

.intro-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 3rem;
  align-items: center;
  padding: 4rem clamp(1.5rem, 6vw, 6rem) 3rem;
}

.intro-hero__content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 460px;
}

.intro-brand {
  text-transform: uppercase;
  letter-spacing: 0.35em;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  opacity: 0.8;
}

.intro-title {
  font-size: clamp(2.5rem, 5vw, 3.75rem);
  line-height: 1.1;
  margin: 0;
}

.intro-subtitle {
  font-size: 1.05rem;
  line-height: 1.7;
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
}

.intro-cta {
  align-self: flex-start;
  padding: 0.9rem 2.6rem;
  border-radius: var(--button-radius);
  background: #ffffff;
  color: #1d4ed8;
  font-weight: var(--font-weight-semibold);
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.25);
  transition: transform var(--duration-200) var(--ease-out), box-shadow var(--duration-200) var(--ease-out);
}

.intro-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 38px rgba(15, 23, 42, 0.28);
}

.intro-cta-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.intro-cta--secondary {
  background: transparent;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: none;
}

.intro-cta--secondary:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.2);
}

.intro-hero__visual {
  position: relative;
  display: flex;
  justify-content: center;
}

.intro-hero__frame {
  width: clamp(220px, 40vw, 340px);
  aspect-ratio: 1;
  border-radius: 36px;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), rgba(59,130,246,0.35));
  display: grid;
  place-items: center;
  box-shadow: 0 22px 65px rgba(15, 23, 42, 0.4);
}

.intro-hero__cloud {
  width: 55%;
  aspect-ratio: 1.8 / 1;
  background: #ffffff;
  border-radius: 999px;
  position: relative;
}

.intro-hero__cloud::before,
.intro-hero__cloud::after {
  content: '';
  position: absolute;
  background: #ffffff;
  border-radius: 50%;
}

.intro-hero__cloud::before {
  width: 55%;
  height: 55%;
  top: -35%;
  left: 10%;
}

.intro-hero__cloud::after {
  width: 45%;
  height: 45%;
  top: -30%;
  right: 12%;
}

.intro-section {
  background: #ffffff;
  color: var(--text);
  padding: clamp(3rem, 8vw, 5rem) clamp(1.5rem, 7vw, 6rem);
}

.intro-story {
  display: grid;
  gap: 2rem;
  align-items: center;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.intro-story__illustration {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
}

.intro-story__card {
  width: clamp(90px, 20vw, 140px);
  aspect-ratio: 1 / 2;
  border-radius: 2rem;
  background: linear-gradient(180deg, #60a5fa 0%, #2563eb 65%, #1e3a8a 100%);
  box-shadow: 0 18px 28px rgba(15, 23, 42, 0.18);
}

.intro-story__card--secondary {
  align-self: flex-end;
  background: linear-gradient(180deg, #c4dfff 0%, #2563eb 80%);
}

.intro-story__content h2 {
  font-size: clamp(2rem, 4vw, 2.6rem);
  margin-bottom: 1.25rem;
}

.intro-story__content p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 480px;
}

.intro-services {
  text-align: center;
  background: linear-gradient(180deg, #2563eb 0%, #0f172a 100%);
  color: #ffffff;
}

.intro-services h2 {
  font-size: clamp(2.1rem, 4vw, 2.8rem);
  margin-bottom: 2rem;
}

.intro-services__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.intro-service-card {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 2rem 1.75rem;
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.25);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.intro-service-card h3 {
  margin: 0;
  font-size: 1.25rem;
}

.intro-service-card p {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.6;
}

.intro-connect h2 {
  font-size: clamp(2rem, 3.5vw, 2.4rem);
  margin-bottom: 2rem;
  text-align: center;
}

.intro-connect__grid {
  display: grid;
  gap: 2.5rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.intro-connect__grid ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

.intro-connect__label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.intro-connect a {
  color: var(--primary);
  font-weight: var(--font-weight-semibold);
}

@media (max-width: 640px) {
  .intro-hero {
    padding-top: 3.5rem;
    padding-bottom: 2.5rem;
  }

  .intro-services__grid,
  .intro-connect__grid,
  .intro-story {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .intro-story__illustration {
    justify-content: center;
  }

  .intro-story__content p {
    margin: 0 auto;
  }

  .intro-service-card {
    text-align: center;
    align-items: center;
  }

  .intro-cta {
    width: 100%;
    justify-content: center;
  }
}

main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
  padding-bottom: calc(96px + var(--safe-area-bottom));
  box-sizing: border-box;
}

#app {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  flex: 1 1 auto;
}

/* Re-enable text selection for input fields */
input, textarea, [contenteditable] {
  -webkit-user-select: text;
  -khtml-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* Mobile-first responsive adjustments */
@media (min-width: 768px) {
  body {
    /* Re-enable hover effects on larger screens */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }
}

/* ============ TYPOGRAPHY SYSTEM ============ */
h1 {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin: 0 0 var(--spacing-xl) 0;
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin: 0 0 var(--spacing-lg) 0;
  letter-spacing: -0.01em;
}

h3 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  margin: 0 0 var(--spacing-md) 0;
}

h4 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--spacing-md) 0;
}

h5 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--spacing-sm) 0;
}

h6 {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--spacing-sm) 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

p {
  margin: 0 0 var(--spacing-md) 0;
  line-height: var(--line-height-relaxed);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition-colors);
}

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

small {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-normal);
}

/* ============ BUTTON STYLES ============ */
button {
  font-family: inherit;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  border: none;
  border-radius: var(--button-radius);
  cursor: pointer;
  padding: calc(var(--spacing-md) + 2px) calc(var(--spacing-xl) + 4px);
  min-height: 44px;
  min-width: 44px;
  transition: var(--transition-transform), var(--transition-colors), box-shadow var(--duration-300) var(--ease-out);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
}

button:not(:disabled) {
  cursor: pointer;
}

button:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

button:not(:disabled):active {
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary Button */
.btn-primary {
  background: linear-gradient(140deg, var(--brand-gradient-start), var(--brand-gradient-end));
  color: #ffffff;
  box-shadow: var(--brand-shadow);
}

.btn-primary:not(:disabled):hover {
  background: linear-gradient(140deg, var(--brand-gradient-hover-start), var(--brand-gradient-hover-end));
  box-shadow: 0 20px 36px rgba(141, 160, 255, 0.38);
}

/* Secondary Button */
.btn-secondary {
  background: rgba(255, 255, 255, 0.9);
  color: var(--primary-dark);
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
}

.btn-secondary:not(:disabled):hover {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.14);
}

/* Success Button */
.btn-success {
  background: linear-gradient(140deg, var(--accent-light), var(--accent));
  color: #ffffff;
  box-shadow: 0 16px 32px rgba(16, 185, 129, 0.28);
}

.btn-success:not(:disabled):hover {
  background: linear-gradient(140deg, var(--accent), var(--accent-dark));
  box-shadow: 0 20px 38px rgba(16, 185, 129, 0.35);
}

/* Danger Button */
.btn-danger {
  background: linear-gradient(140deg, #ff7b7b, var(--error));
  color: #ffffff;
  box-shadow: 0 16px 32px rgba(239, 68, 68, 0.28);
}

.btn-danger:not(:disabled):hover {
  background: linear-gradient(140deg, #ff9696, var(--error-dark));
  box-shadow: 0 20px 38px rgba(239, 68, 68, 0.35);
}

/* Text Button */
.btn-text {
  background: transparent;
  color: var(--primary);
  padding: var(--spacing-sm) var(--spacing-md);
}

.btn-text:not(:disabled):hover {
  background: rgba(59, 130, 246, 0.1);
}

/* Icon Button */
.btn-icon {
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

/* Login experience */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 6vw, 56px);
  background: linear-gradient(160deg, #cfe3ff 0%, #f7d5ff 52%, #ffd8cf 100%);
}

.login-card {
  width: 100%;
  max-width: 960px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: rgba(255, 255, 255, 0.86);
  border-radius: 32px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 40px 80px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(20px);
}

@media (max-width: 860px) {
  .login-card {
    grid-template-columns: 1fr;
  }
}

.login-hero {
  position: relative;
  padding: clamp(36px, 6vw, 56px);
  background: linear-gradient(180deg, rgba(118, 135, 255, 0.95) 0%, rgba(255, 111, 167, 0.92) 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 5vw, 48px);
  justify-content: space-between;
  overflow: hidden;
}

.login-hero::before,
.login-hero::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.login-hero::before {
  width: 220px;
  height: 220px;
  top: -80px;
  right: -60px;
  background: rgba(255, 255, 255, 0.22);
}

.login-hero::after {
  width: 280px;
  height: 280px;
  bottom: -110px;
  left: -60px;
  background: rgba(255, 255, 255, 0.18);
}

.login-tag {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: rgba(17, 24, 39, 0.22);
  padding: 8px 16px;
  border-radius: 999px;
  width: fit-content;
}

.login-hero h2 {
  font-size: clamp(30px, 4vw, 42px);
  margin: 0;
  line-height: 1.1;
}

.login-hero p {
  margin: 0;
  font-size: clamp(16px, 2.4vw, 18px);
  opacity: 0.88;
}

.login-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.login-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  font-size: 14px;
  font-weight: 600;
}

.login-pill::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
}

.login-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.login-stat-card {
  background: rgba(17, 24, 39, 0.18);
  border-radius: 24px;
  padding: 16px 20px;
  min-width: 160px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.login-stat-card strong {
  display: block;
  font-size: 24px;
  margin-bottom: 6px;
}

.login-stat-card span {
  font-size: 13px;
  opacity: 0.8;
}

.login-form {
  padding: clamp(32px, 5vw, 56px);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.login-form header h2 {
  margin: 0 0 12px 0;
  font-size: clamp(26px, 3vw, 34px);
  color: var(--text);
}

.login-form header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
}

.login-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-google {
  background: #ffffff;
  color: #1f2937;
  border: 2px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 14px 26px rgba(66, 133, 244, 0.18);
}

.login-google svg {
  flex-shrink: 0;
}

.login-google:hover {
  box-shadow: 0 18px 32px rgba(66, 133, 244, 0.22);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(15, 23, 42, 0.12);
}

.login-select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 2px solid rgba(15, 23, 42, 0.08);
  background: rgba(249, 250, 251, 0.9);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  transition: var(--transition-colors);
}

.login-select-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.login-select:focus {
  outline: none;
  border-color: rgba(118, 135, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(118, 135, 255, 0.18);
}

.login-disclaimer {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  background: rgba(249, 250, 251, 0.78);
  border-radius: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.login-disclaimer strong {
  color: var(--primary-dark);
}

.login-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  font-size: 12px;
  color: var(--text-muted);
}

.login-footer span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Mobile-specific optimizations */
.mobile-optimized {
  /* Ensure content doesn't get hidden behind mobile UI */
  padding-bottom: calc(96px + var(--safe-area-bottom));
  min-height: 100dvh; /* Dynamic viewport height for mobile */
}

/* Touch-friendly cards and interactive elements */
.card-touch {
  min-height: 48px;
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
}

.quiz-option {
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  touch-action: manipulation;
}

.quiz-option:active {
  transform: scale(0.98);
  transition: transform 0.1s ease;
}

/* Mobile navigation improvements */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: auto;
  background: var(--card-bg);
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
  display: flex;
  z-index: 2000;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: var(--spacing-xs) var(--spacing-md) calc(var(--safe-area-bottom) + var(--spacing-sm));
}

.bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xs) var(--spacing-xs);
  padding-bottom: calc(var(--spacing-xs) + var(--safe-area-bottom) / 2);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all 0.2s ease;
  border-radius: 0;
  min-height: 56px;
}

.bottom-nav button:active {
  background: rgba(0, 0, 0, 0.05);
  transform: none;
}

/* ============ FORM INPUTS ============ */
input,
textarea,
select {
  font-family: inherit;
  font-size: 16px; /* Prevents auto-zoom on iOS */
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  transition: var(--transition-all);
  width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  line-height: var(--line-height-normal);
}

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

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: var(--card-bg);
}

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

/* Select dropdown customization */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right var(--spacing-lg) center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

/* Textarea */
textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--font-family-mono);
}

/* Form wrapper */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
}

label {
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-sm);
  color: var(--text);
}

.form-error {
  color: var(--error);
  font-size: var(--font-size-xs);
  margin-top: var(--spacing-xs);
}

.form-help {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  margin-top: var(--spacing-xs);
}

.form-help {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  margin-top: var(--spacing-xs);
}

/* ============ CARD STYLES ============ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  padding: var(--spacing-xl);
  transition: var(--transition-all);
  box-shadow: var(--shadow);
}

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

.card.elevated {
  box-shadow: var(--shadow-lg);
}

.card-header {
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid var(--border);
}

.card-body {
  margin-bottom: var(--spacing-lg);
}

.card-footer {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--border);
}

/* ============ CONTAINER & GRID ============ */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

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

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

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

@media (max-width: 768px) {
  .container {
    max-width: 100%;
    padding: 0 var(--spacing-md);
  }

  header .container {
    padding: 0;
    gap: var(--spacing-md);
  }

  header h1 {
    font-size: var(--font-size-xl);
  }
}

/* Responsive grid */
.grid {
  display: grid;
  gap: var(--spacing-lg);
}

.grid-cols-1 {
  grid-template-columns: 1fr;
}

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

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

.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1024px) {
  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

/* Flexbox utilities */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-row {
  flex-direction: row;
}

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

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

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.gap-xl { gap: var(--spacing-xl); }

/* ============ SPACING UTILITIES ============ */
.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }

.m-sm { margin: var(--spacing-sm); }
.m-md { margin: var(--spacing-md); }
.m-lg { margin: var(--spacing-lg); }
.m-xl { margin: var(--spacing-xl); }

/* ============ MODAL STYLES ============ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: var(--spacing-xl);
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

/* Swipe gestures support */
.swipe-container {
  touch-action: pan-y;
  overflow-x: hidden;
}

/* Mobile landscape adjustments */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .bottom-nav {
    height: 48px;
  }

  .bottom-nav button {
    min-height: 48px;
    font-size: 12px;
  }

  .mobile-optimized {
    padding-bottom: 60px;
  }
}

/* Tablet adjustments */
@media (min-width: 768px) {
  .bottom-nav {
    display: flex; /* Show bottom nav on tablets/desktop as well */
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    max-width: 400px;
    border-radius: 16px 16px 0 0;
    margin-bottom: 20px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  }

  .bottom-nav button {
    flex: 1;
    min-width: 80px;
    padding: 12px 8px;
    font-size: 14px;
  }

  .mobile-optimized {
    padding-bottom: var(--spacing-xl);
  }

  .modal-content {
    max-width: 500px;
  }
}

.btn-secondary:hover:not(:disabled) {
  background: var(--card-bg);
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
    
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(20px); }
      to { opacity: 1; transform: translateY(0); }
    }
    
    @keyframes slideIn {
      from { opacity: 0; transform: translateX(-20px); }
      to { opacity: 1; transform: translateX(0); }
    }
    
    .fade-in {
      animation: fadeIn 0.6s ease-out;
    }
    
    .slide-in {
      animation: slideIn 0.4s ease-out;
    }
    
    .card-3d {
      perspective: 1000px;
    }
    
    .card-inner {
      position: relative;
      width: 100%;
      height: 100%;
      transition: transform 0.6s;
      transform-style: preserve-3d;
    }
    
    .card-inner.flipped {
      transform: rotateY(180deg);
    }
    
    .card-front, .card-back {
      position: absolute;
      width: 100%;
      height: 100%;
      backface-visibility: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 2rem;
      border-radius: 1rem;
    }
    
    .card-back {
      transform: rotateY(180deg);
    }
    
    .category-card {
      transition: all 0.3s ease;
      cursor: pointer;
    }
    
    .category-card:hover {
      transform: translateY(-8px);
      box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    }
    
    .progress-bar {
      transition: width 0.4s ease;
    }

    .modal-overlay {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(15, 23, 42, 0.6);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 1000;
      padding: 1rem;
    }

    .modal-content {
      max-width: 500px;
      width: 100%;
      max-height: 90%;
      overflow-y: auto;
      border-radius: 1rem;
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }

#toast {
  position: fixed;
  top: 2rem;
  right: 2rem;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
 z-index: 1000;
}

#toast.show {
  opacity: 1;
  transform: translateX(0);
}

.loading {
  position: relative;
  width: 80px;
  height: 80px;
}

.loading {
  position: relative;
  width: 80px;
  height: 80px;

  background: url("icons/loading.svg") no-repeat center;
  background-size: contain;

  animation: spin 2s linear infinite;
  overflow: hidden;
}

/* shimmer light sweep */
.loading::after {
  content: "";
  position: absolute;
  inset: 0;

  background: linear-gradient(
    120deg,
    transparent 30%,
    rgba(255,255,255,0.6) 50%,
    transparent 70%
  );

  animation: light-run 1.5s linear infinite;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(0, 0, 0, 0.4);
  z-index: 9999;

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.loading-overlay.show {
  opacity: 1;
  pointer-events: auto;
}


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

@keyframes light-run {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

/* ===== MODAL ===== */
.modal {
  background: rgba(15, 23, 42, 0.6);
  width: 90%;
  max-width: 420px;
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgb(44 19 19 / 25%);
}

.modal h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
  color: #dad2d2;
}

/* ===== INPUTS ===== */
.modal label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #cbcbcb ;
}

.modal input {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid #938989;
  font-size: 1rem;
}

/* ===== ACTIONS ===== */
.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
#confirmAIModal {
  color: #7b9afb;
}
#cancelAIModal {
  color: #ffdbdb;
}
.quiz-option:hover {
  transform: translateY(-2px);
}

.quiz-option:active {
  transform: scale(0.98);
}

.quiz-option.correct {
  background: #22c55e !important;
  color: white;
}

.quiz-option.wrong {
  background: #ef4444 !important;
  color: white;
}

.quiz-option.disabled {
  pointer-events: none;
  opacity: 0.8;
}

.fade-in {
  animation: fadeIn 0.25s ease;
}

@font-face {
  font-family: "BBHBartle";
  src: url("fonts/BBHBartle-Regular.ttf") format("truetype");
}

@font-face {
  font-family: "BBHBogle";
  src: url("fonts/BBHBogle-Regular.ttf") format("truetype");
}

@font-face {
  font-family: "BBHHegarty";
  src: url("fonts/BBHHegarty-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Google Sans Italic";
  src: url("fonts/GoogleSans-Italic-VariableFont_GRAD\,opsz\,wght.ttf") format("truetype");
}
@font-face {
  font-family: "Google Sans";
  src: url("fonts/GoogleSans-VariableFont_GRAD\,opsz\,wght.ttf") format("truetype");
}
@font-face {
  font-family: "Open Sans Italic";
  src: url("fonts/OpenSans-Italic-VariableFont_wdth\,wght.ttf") format("truetype");
}
@font-face {
  font-family: "Open Sans";
  src: url("fonts/OpenSans-VariableFont_wdth\,wght.ttf") format("truetype");
}
@font-face {
  font-family: "Playfair Display Italic";
  src: url("fonts/PlayfairDisplay-Italic-VariableFont_wght.ttf") format("truetype");
}
@font-face {
  font-family: "Playfair Display";
  src: url("fonts/PlayfairDisplay-VariableFont_wght.ttf") format("truetype");
}
@font-face {
  font-family: "Roboto Italic";
  src: url("fonts/Roboto-Italic-VariableFont_wdth\,wght.ttf") format("truetype");
}
@font-face {
  font-family: "Roboto";
  src: url("fonts/Roboto-VariableFont_wdth\,wght.ttf") format("truetype");
}
@font-face {
  font-family: "Orbitron";
  src: url("fonts/Orbitron-VariableFont_wght.ttf") format("truetype");
}

.settings-fab:hover {
  transform: scale(1.08) rotate(10deg);
  box-shadow: 0 16px 40px rgba(0,0,0,.3);
}
.settings-fab:active {
  transform: scale(0.95) rotate(0deg);
  box-shadow: 0 8px 20px rgba(0,0,0,.2);
}
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);

  display: flex;
  justify-content: center;
  align-items: flex-start;   /* 👈 important */

  padding: 1rem;          /* 👈 breathing room at top */
  overflow-y: auto;

  z-index: 1300;
  animation: fadeIn .2s ease;
}


.settings-modal {
  width: 100%;
  max-width: 420px;

  max-height: calc(100vh - 2.5rem); /* 👈 key */
  overflow-y: auto;

  background: var(--card-bg);
  border-radius: 22px;
  padding: 1.75rem;

  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  animation: slideUp .25s ease;
  font-family: var(--font-family);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.settings-header h2 {
  font-size: 1.25rem;
  color: var(--text);
}

.settings-header button {
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
}

.settings-group {
  margin-bottom: 1.25rem;
}

.settings-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: .4rem;
  color: var(--text);
  opacity: .8;
}

.settings-group input[type="color"] {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
}

.settings-group select,
.settings-group input[type="range"] {
  width: 100%;
  padding: .6rem;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.1);
  background: var(--background);
  color: var(--text);
}

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

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
}
      
    @keyframes slideIn {
      from { opacity: 0; transform: translateX(-20px); }
      to { opacity: 1; transform: translateX(0); }
    }
    
    .fade-in {
      animation: fadeIn 0.6s ease-out;
    }
    
    .slide-in {
      animation: slideIn 0.4s ease-out;
    }
    
    .card-3d {
      perspective: 1000px;
    }
    
    .card-inner {
      position: relative;
      width: 100%;
      height: 100%;
      transition: transform 0.6s;
      transform-style: preserve-3d;
    }
    
    .card-inner.flipped {
      transform: rotateY(180deg);
    }
    
    .card-front, .card-back {
      position: absolute;
      width: 100%;
      height: 100%;
      backface-visibility: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 2rem;
      border-radius: 1rem;
    }
    
    .card-back {
      transform: rotateY(180deg);
    }
    
    .category-card {
      transition: all 0.3s ease;
      cursor: pointer;
    }
    
    .category-card:hover {
      transform: translateY(-8px);
      box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    }
    
    .progress-bar {
      transition: width 0.4s ease;
    }

    .modal-overlay {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(15, 23, 42, 0.6);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 1000;
      padding: 1rem;
    }

    .modal-content {
      max-width: 500px;
      width: 100%;
      max-height: 90%;
      overflow-y: auto;
      border-radius: 1rem;
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }

#toast {
  position: fixed;
  top: 2rem;
  right: 2rem;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
 z-index: 1000;
}

#toast.show {
  opacity: 1;
  transform: translateX(0);
}

.icon {
  width: 120px;
  height: 120px;
}

.icon.sm { width: 30px; height: 30px; }
.icon.md { width: 30px; height: 30px; }
.icon.lg { width: 36px; height: 36px; }
.icon.xl { width: 44px; height: 44px; }

#confirmAIModal {
  color: #7b9afb;
}
#cancelAIModal {
  color: #ffdbdb;
}
.quiz-option:hover {
  transform: translateY(-2px);
}

.quiz-option:active {
  transform: scale(0.98);
}

.quiz-option.correct {
  background: #22c55e !important;
  color: white;
}

.quiz-option.wrong {
  background: #ef4444 !important;
  color: white;
}

.quiz-option.disabled {
  pointer-events: none;
  opacity: 0.8;
}

.fade-in {
  animation: fadeIn 0.25s ease;
}

@font-face {
  font-family: "BBHBartle";
  src: url("fonts/BBHBartle-Regular.ttf") format("truetype");
}

@font-face {
  font-family: "BBHBogle";
  src: url("fonts/BBHBogle-Regular.ttf") format("truetype");
}

@font-face {
  font-family: "BBHHegarty";
  src: url("fonts/BBHHegarty-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Google Sans Italic";
  src: url("fonts/GoogleSans-Italic-VariableFont_GRAD\,opsz\,wght.ttf") format("truetype");
}
@font-face {
  font-family: "Google Sans";
  src: url("fonts/GoogleSans-VariableFont_GRAD\,opsz\,wght.ttf") format("truetype");
}
@font-face {
  font-family: "Open Sans Italic";
  src: url("fonts/OpenSans-Italic-VariableFont_wdth\,wght.ttf") format("truetype");
}
@font-face {
  font-family: "Open Sans";
  src: url("fonts/OpenSans-VariableFont_wdth\,wght.ttf") format("truetype");
}
@font-face {
  font-family: "Playfair Display Italic";
  src: url("fonts/PlayfairDisplay-Italic-VariableFont_wght.ttf") format("truetype");
}
@font-face {
  font-family: "Playfair Display";
  src: url("fonts/PlayfairDisplay-VariableFont_wght.ttf") format("truetype");
}
@font-face {
  font-family: "Roboto Italic";
  src: url("fonts/Roboto-Italic-VariableFont_wdth\,wght.ttf") format("truetype");
}
@font-face {
  font-family: "Roboto";
  src: url("fonts/Roboto-VariableFont_wdth\,wght.ttf") format("truetype");
}

.settings-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 22px;
  border: none;
  box-shadow: 0 12px 30px rgba(0,0,0,.25);
  cursor: pointer;
  z-index: 1200;
  transition: transform .2s ease, box-shadow .2s ease;
}

.settings-fab:hover {
  transform: scale(1.08) rotate(10deg);
  box-shadow: 0 16px 40px rgba(0,0,0,.3);
}
.settings-fab:active {
  transform: scale(0.95) rotate(0deg);
  box-shadow: 0 8px 20px rgba(0,0,0,.2);
}
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1300;
  animation: fadeIn .2s ease;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.settings-header h2 {
  font-size: 1.25rem;
  color: var(--text);
}

.settings-header button {
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
}

.settings-group {
  margin-bottom: 1.25rem;
}

.settings-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: .4rem;
  color: var(--text);
  opacity: .8;
}

.settings-group input[type="color"] {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
}

.settings-group select,
.settings-group input[type="range"] {
  width: 100%;
  padding: .6rem;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.1);
  background: var(--background);
  color: var(--text);
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.theme-tile {
  padding: 12px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: var(--background);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, border 0.15s ease;
}

.theme-tile:hover {
  transform: translateY(-1px);
}

.theme-tile.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 15%, var(--background));
}

/* ===== LAYOUT ===== */
.subjects-view {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  background: var(--background);
}

.subjects-wrapper {
  min-height: 100%;
  display: flex;
  justify-content: center;
  padding: 2rem;
}

.subjects-container {
  width: 100%;
  max-width: 64rem;
}

/* ===== HERO ===== */
.subjects-hero {
  text-align: center;
  margin-bottom: 3rem;
}

.subjects-title {
  font-size: calc(var(--font-size) * 2.5);
  font-weight: 700;
  color: var(--text);
  margin-bottom: .5rem;
}

.subjects-subtitle {
  font-size: calc(var(--font-size) * 1.1);
  color: rgba(128, 128, 128, 0.6);
}

/* ===== ACTION ===== */
.subjects-actions {
  margin-bottom: 1.5rem;
}

.add-subject-btn {
  width: 100%;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: calc(var(--font-size) * 1.1);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--primary), transparent 60%);
}

/* ===== GRID ===== */
.subjects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .subjects-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== CARD ===== */
.category-card {
  font-size: calc(var(--font-size) * 1.4);
  font-weight: 500;
  color: var(--text);
  position: relative;
  padding: 1.5rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0,0,0,.08);
  transition: transform .15s ease, box-shadow .15s ease;
}

.category-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0,0,0,.12);
}

/* ===== DELETE ===== */
.delete-subject-btn {
  position: absolute;
  top: .75rem;
  right: .75rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: rgba(128, 128, 128, 0.6);
  opacity: 0.6;
}

/* ===== CARD CONTENT ===== */
.category-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.category-title {
  font-size: calc(var(--font-size) * 1.4);
  font-weight: 500;
  color: var(--text);        
}

.category-subtitle {
  font-size: calc(var(--font-size) * 0.9);
  color: var(--text-muted);    
  opacity: 0.8;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.category-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(
    135deg,
    var(--primary),
    color-mix(in srgb, var(--primary), black 20%)
  );
}

.category-icon-text {
  font-size: calc(var(--font-size) * 1.4);
}

.category-title {
  font-size: calc(var(--font-size) * 1.4);
  font-weight: 500;
  color: var(--text);
}

.category-subtitle {
  font-size: calc(var(--font-size) * .85);
  color: rgba(128, 128, 128, 0.55); /* Fallback for older browsers */
  color: color-mix(in srgb, var(--text), transparent 45%);
}

/* ===== EMPTY ===== */
.subjects-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: rgba(128, 128, 128, 0.55); /* Fallback for older browsers */
  color: color-mix(in srgb, var(--text), transparent 45%);
}


/* ===== LAYOUT ===== */
.view-container-cards {
  width: 100%;
  height: 100%;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
}

.view-content-cards {
  min-height: 100%;
  padding: 1.5rem;
}

.view-inner-cards {
  max-width: 64rem;
  margin: 0 auto;
}

/* ===== HEADER ===== */
.cards-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.btn-back {
  width: 50px;
  padding: 0.5rem 0.5rem;
  border-radius: 0.5rem;
  background: white;
  color: var(--text);
  font-size: var(--font-size);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.cards-title{
  place-items: center;
}
.cards-title h2 {
  font-size: calc(var(--font-size) * 1.8);
  font-weight: 400;
}

.cards-title p {
  font-size: calc(var(--font-size) * 0.85);
  opacity: 0.7;
  justify-content: center;
}

.header-spacer {
  width: 3rem;
}

/* ===== ACTION BAR ===== */
.cards-actions {
  overflow-x: auto;
}

.cards-actions::-webkit-scrollbar {
  display: none;
}

.actions-inner {
  display: flex;
  gap: 5px;
  padding: 0.25rem 0.25rem 0.75rem;

  width: max-content;      /* 👈 magic */
  margin-inline: auto;     /* 👈 centers when it fits */
}

.cards-actions::after {
  content: "";
  position: sticky;
  right: 0;
  width: 32px;
  pointer-events: none;
  background: linear-gradient(
    to left,
    var(--background),
    transparent
  );
}

.cards-actions::-webkit-scrollbar {
  display: none;              /* Chrome / Safari */
}

.action-btn {
  flex: 0 0 auto;              /* IMPORTANT */
  min-width: 100px;
  min-height: 100px;
  background: #ffffff;
  border-radius: var(--radius);

  display: flex;
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
  touch-action: manipulation;
  scroll-snap-align: center;
  flex-direction: column;   
  align-items: center;      
  justify-content: center;  
}
.action-btn .icon {
  display: block;
  width: 80px;   
  height: 60px;
}

.action-label{
  color: #28577f;
}
.action-btn:active {
  transform: scale(0.96);
}

/* ===== CARDS ===== */
.cards-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, max-content));
  justify-content: center;
  gap: 1rem;
}



.card-item {
  width: min(300px, 100%);
  justify-content: center;
  align-items: center;
  position: relative;
  padding: 1rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.card-delete-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  font-size: 1.2em;
  color: var(--text);
  opacity: 0.6;
}

/* ===== CARD CONTENT ===== */
.card-section {
  margin-bottom: 0.75rem;
  justify-content: center;
  align-items: center;
}

.card-label {
  font-size: 0.75em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.25rem;
  text-align: center;
}

.card-text {
  font-size: var(--font-size);
  text-align: center;
}

.card-answer {
  opacity: 0.8;
}

/* ===== EMPTY STATE ===== */
.cards-empty {
  text-align: center;
  padding: 3rem 1rem;
  opacity: 0.7;
  font-size: calc(var(--font-size) * 1.2);
}

.study-timer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0,0,0,0.05);
  font-weight: 600;
}

.timer-settings {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.timer-settings input {
  width: 90px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid #ccc;
}

.timer-settings button {
  padding: 6px 12px;
  border-radius: 8px;
}

.quiz-timer {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;

  display: flex;
  align-items: center;
  gap: 8px;

  padding: 10px 16px;
  border-radius: 999px;

  font-weight: 600;
  font-size: 14px;

  background: rgba(0, 0, 0, 0.08);
  color: var(--text);

  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);

  transition: background 0.3s ease, color 0.3s ease;
}

/* Warning: under 1 minute */
.quiz-timer.warning {
  background: rgba(255, 165, 0, 0.15);
  color: #d97706;
}

/* Danger: under 10 seconds */
.quiz-timer.danger {
  background: rgba(220, 38, 38, 0.18);
  color: #dc2626;
}

/* ===== DASHBOARD CARDS ===== */
.dashboard-card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  cursor: pointer;
  background: rgba(0,0,0,.04);
}

.dashboard-header:hover {
  filter: brightness(.97);
}

.dashboard-body {
  padding: 16px;
}

.dashboard-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dashboard-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.score-good { color: var(--primary); font-weight: 600; }
.score-bad { color: #dc2626; font-weight: 600; }

.hidden { display: none; }

.dashboard-body {
  animation: fadeIn .2s ease;
}

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

#student-score-container {
  max-height: 70vh;
  overflow-y: auto;
}

body.bottom-nav-visible .settings-fab {
  width: 48px;
  height: 48px;
  font-size: 18px;
  bottom: 60px;  /* lifted above bottom nav */
}

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-bar div {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: var(--card-bg);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease-out;
  pointer-events: auto;
}

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

/* Selected choice animation */
.selected {
  animation: pulse 0.6s ease-in-out infinite;
}

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

/* Utility Classes */
.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-text { color: var(--text); }
.text-text-muted { color: var(--text-muted); }

.bg-primary { background-color: var(--primary); }
.bg-secondary { background-color: var(--secondary); }
.bg-surface { background-color: var(--surface); }
.bg-card { background-color: var(--card-bg); }

/* File Input Styling */
input[type="file"] {
  padding: 8px;
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
}

input[type="file"]::-webkit-file-upload-button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-right: 10px;
}

input[type="file"]::-webkit-file-upload-button:hover {
  background: var(--primary-hover);
}

/* Loading Spinner */
.animate-spin {
  animation: spin 1s linear infinite;
}

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

/* PWA Install Button */
.pwa-install-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: all 0.2s ease;
}

.pwa-install-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Network Status Indicator */
.network-status {
  position: fixed;
  top: 10px;
  right: 10px;
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  z-index: 1001;
  transition: all 0.3s ease;
}

.network-status.online {
  background: rgba(34, 197, 94, 0.9);
  color: white;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.network-status.offline {
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Offline Message */
.offline-message {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.offline-content {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: var(--radius);
  text-align: center;
  max-width: 400px;
  margin: 1rem;
  box-shadow: var(--shadow-lg);
}

.offline-content h2 {
  color: var(--text);
  margin-bottom: 1rem;
}

.offline-content p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Cache Status Indicator */
.cache-status {
  position: fixed;
  bottom: 80px;
  right: 20px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  z-index: 1001;
  max-width: 200px;
  word-wrap: break-word;
  transition: all 0.3s ease;
}

.cache-status.info {
  background: var(--primary);
  color: white;
}

.cache-status.success {
  background: var(--success);
  color: white;
}

.cache-status.error {
  background: var(--error);
  color: white;
}

/* Enhanced Quiz Styles */
.quiz-option:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

.quiz-option:active {
  transform: translateY(-2px) scale(0.98);
  transition-duration: 0.1s;
}

.quiz-option.correct {
  background: linear-gradient(135deg, #22c55e, #16a34a) !important;
  color: white !important;
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(34, 197, 94, 0.3) !important;
  animation: correctPulse 0.6s ease-out;
}

.quiz-option.wrong {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  color: white !important;
  transform: scale(0.95);
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3) !important;
  animation: wrongShake 0.6s ease-out;
}

.quiz-option.disabled {
  pointer-events: none;
  opacity: 0.7;
  transform: none !important;
}

.quiz-option.selected {
  transform: scale(1.03);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  animation: selectedGlow 0.4s ease-out;
}

/* Quiz animations */
@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1.05); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0) scale(0.95); }
  25% { transform: translateX(-5px) scale(0.95); }
  75% { transform: translateX(5px) scale(0.95); }
}

@keyframes selectedGlow {
  0% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
  50% { box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3); }
  100% { box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15); }
}

/* Enhanced fade-in animation */
.fade-in {
  animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Progress bar enhancements */
.progress-bar {
  position: relative;
  width: 100%;
  height: 12px;
  background: linear-gradient(135deg, rgba(0,0,0,0.1), rgba(0,0,0,0.05));
  border-radius: 20px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progress-bar > div {
  height: 100%;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
}

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

@keyframes progressShine {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Glass morphism effects */
.glass-card {
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* Button hover effects */
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Timer floating animation */
@keyframes timerFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-5px); }
}

#floating-timer {
  animation: timerFloat 3s ease-in-out infinite;
}

/* PDF Viewer Styles */
.pdf-content {
  font-family: 'Georgia', serif;
  font-size: 16px;
  line-height: 1.6;
  padding: 16px;
  border-radius: 8px;
  overflow-y: auto;
  max-height: 70vh;
  color: var(--text);
  transition: font-size 0.2s ease;
}

.pdf-viewer-container {
  padding: 16px;
}

.pdf-header {
  margin-bottom: 8px;
}

.pdf-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.pdf-content-area {
  overflow: hidden;
  position: relative;
  margin-bottom: 8px;
}

#pdf-canvas {
  transition: transform 0.25s ease;
}

.pdf-footer {
  margin-top: 8px;
}

.pdf-item {
  transition: all 0.2s ease;
}

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

.pdf-icon {
  font-size: 24px;
  opacity: 0.8;
}

.pdf-arrow {
  font-size: 18px;
  opacity: 0.6;
}

/* Animation for loading spinner */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Fullscreen styles */
.pdf-viewer-container:fullscreen {
  padding: 20px;
  background: var(--background);
}
/* Fullscreen PDF mode */
.pdf-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #000;
  z-index: 9999;
}

.pdf-fullscreen #pdf-content {
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  overflow: hidden !important;
  padding: 0 !important;
}

.pdf-fullscreen canvas {
  width: 100vw !important;
  height: 100vh !important;
  object-fit: contain;
}

body.pdf-lock {
  overflow: hidden;
}


/* PDF Viewer Mobile Optimizations */
@media (max-width: 767px) {
  .pdf-viewer-container {
    padding: 8px;
    max-width: 100vw;
  }

  .pdf-header {
    padding: 12px;
    margin-bottom: 8px;
  }

  .pdf-toolbar {
    padding: 8px 12px;
  }

  .pdf-content {
    padding: 8px;
    min-height: 50vh;
    max-height: 60vh;
  }

  .pdf-footer {
    padding: 12px;
    margin-top: 8px;
  }

  .pdf-footer button {
    padding: 8px 12px;
    font-size: 12px;
  }

  #page-input {
    width: 40px;
    font-size: 14px;
  }
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .pdf-content canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Touch-friendly PDF controls */
.pdf-viewer-container button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.pdf-viewer-container input[type="number"] {
  touch-action: manipulation;
}

/* PDF loading animation */
.pdf-loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
}

/* PDF zoom controls animation */
.pdf-zoom-controls button:active {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}

/* PDF navigation smooth scrolling */
.pdf-content {
  scroll-behavior: smooth;
}

/* PDF fullscreen mode - USE FULL SCREEN SPACE */
.pdf-viewer-container:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column;
  background: var(--background);
  z-index: 9999;
}

.pdf-viewer-container:fullscreen .pdf-header {
  flex-shrink: 0;
  border-radius: 0;
  margin-bottom: 0;
  padding: 12px !important;
  background: var(--card-bg) !important;
}

.pdf-viewer-container:fullscreen .pdf-content-area {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-radius: 0;
  max-height: none;
}

/* Profile view enhancements */
.profile-hero {
  gap: var(--spacing-xl);
}

.info-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: var(--spacing-sm) 0;
}

.info-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.info-value {
  font-size: 0.95rem;
  color: var(--text);
  word-break: break-word;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.chip-success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success, #22c55e);
  border-color: rgba(34, 197, 94, 0.4);
}

.chip-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning, #f59e0b);
  border-color: rgba(245, 158, 11, 0.4);
}

.pdf-viewer-container:fullscreen .pdf-content {
  width: 100%;
  height: auto;
  min-height: calc(100vh - 200px);
  max-height: none !important;
  padding: 20px;
  border-radius: 0;
}

.pdf-viewer-container:fullscreen .pdf-toolbar {
  background: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
  border-radius: 0;
}

.pdf-viewer-container:fullscreen .pdf-footer {
  flex-shrink: 0;
  border-radius: 0;
}

/* PDF progress bar animation */
@keyframes progressFill {
  from { width: 0%; }
  to { width: var(--progress-width); }
}

.pdf-progress-bar div {
  animation: progressFill 0.5s ease-out;
}

/* Mobile fullscreen - maximize space */
@media (max-width: 767px) {
  .pdf-viewer-container:fullscreen {
    padding: 0 !important;
  }

  .pdf-viewer-container:fullscreen .pdf-header {
    padding: 8px !important;
  }

  .pdf-viewer-container:fullscreen .pdf-content {
    padding: 12px;
    min-height: calc(100vh - 150px);
  }

  .pdf-viewer-container:fullscreen .pdf-toolbar {
    padding: 6px 8px !important;
  }
}

/* Enhanced UI Animations and Styles */
@keyframes slideIn {
  from {
    transform: translateX(-50%) scaleX(0);
  }
  to {
    transform: translateX(-50%) scaleX(1);
  }
}

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

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

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

.fade-in {
  animation: fadeInUp 0.6s ease-out;
}

/* ============ MODERN ANIMATIONS ============ */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

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

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

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

.animate-slideInRight {
  animation: slideInRight var(--duration-300) var(--ease-out);
}

.animate-slideInLeft {
  animation: slideInLeft var(--duration-300) var(--ease-out);
}

.animate-slideInUp {
  animation: slideInUp var(--duration-300) var(--ease-out);
}

.animate-slideInDown {
  animation: slideInDown var(--duration-300) var(--ease-out);
}

.animate-fadeIn {
  animation: fadeIn var(--duration-300) var(--ease-out);
}

.animate-scaleIn {
  animation: scaleIn var(--duration-300) var(--ease-out);
}

.animate-spin {
  animation: spin var(--duration-700) linear infinite;
}

/* ============ LOADING & SKELETON ============ */
.loading {
  width: 48px;
  height: 48px;
  border: 4px solid var(--surface);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin var(--duration-700) linear infinite;
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface) 0%,
    var(--surface-hover) 50%,
    var(--surface) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

/* ============ BADGES & PILLS ============ */
.badge {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

.badge-primary {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

/* ============ DIVIDER ============ */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--spacing-lg) 0;
}

.divider-vertical {
  width: 1px;
  background: var(--border);
  margin: 0 var(--spacing-lg);
}

/* ============ TEXT UTILITIES ============ */
.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }

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

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }

.font-light { font-weight: var(--font-weight-light); }
.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

/* ============ BACKGROUND UTILITIES ============ */
.bg-primary { background: var(--primary); color: white; }
.bg-secondary { background: var(--secondary); color: white; }
.bg-accent { background: var(--accent); color: white; }
.bg-surface { background: var(--surface); }
.bg-card { background: var(--card-bg); }

/* ============ SHADOW UTILITIES ============ */
.shadow-none { box-shadow: var(--shadow-none); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }
.shadow-2xl { box-shadow: var(--shadow-2xl); }

/* ============ BORDER UTILITIES ============ */
.border { border: 1px solid var(--border); }
.border-t { border-top: 1px solid var(--border); }
.border-r { border-right: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.border-l { border-left: 1px solid var(--border); }

.border-primary { border-color: var(--primary); }
.border-accent { border-color: var(--accent); }

/* ============ DISPLAY & VISIBILITY ============ */
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

.w-full { width: 100%; }
.w-screen { width: 100vw; }
.h-full { height: 100%; }
.h-screen { height: 100vh; }
.h-screen-safe { height: 100dvh; }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-hidden { overflow-x: hidden; }
.overflow-y-auto { overflow-y: auto; }

/* ============ POSITION UTILITIES ============ */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; top: 0; z-index: var(--z-sticky); }

/* ============ TRANSITIONS ============ */
.transition-all {
  transition: var(--transition-all);
}

.transition-colors {
  transition: var(--transition-colors);
}

.transition-transform {
  transition: var(--transition-transform);
}

/* ============ RESPONSIVE UTILITIES ============ */
@media (max-width: 768px) {
  .md\:hidden { display: none; }
  .md\:block { display: block; }
  .md\:flex { display: flex; }
}

@media (min-width: 768px) {
  .md\:grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .md\:grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .lg\:grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

.glass-effect {
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}

.nav-tab {
  position: relative;
  overflow: hidden;
}

.nav-tab::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.nav-tab:hover::before {
  left: 100%;
}

.icon-container .scale-110 {
  transform: scale(1.1);
}

.pdf-item {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.pdf-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.pdf-item:active {
  transform: translateY(0);
  transition-duration: 0.1s;
}

.pdf-arrow {
  transition: all 0.3s ease;
  transform: translateX(0);
}

.pdf-item:hover .pdf-arrow {
  transform: translateX(4px);
  opacity: 1;
}

/* Button hover effects */
.btn-primary, .btn-secondary {
  position: relative;
  overflow: hidden;
}

.btn-primary::before, .btn-secondary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.btn-primary:hover::before, .btn-secondary:hover::before {
  left: 100%;
}

/* Reading mode styles */
.reading-mode {
  filter: sepia(10%) contrast(1.1) brightness(1.05);
  transition: filter 0.3s ease;
}

/* Enhanced card shadows */
.card {
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

/* Storage bar animation */
.storage-bar > div {
  transition: width 0.5s ease-out, background 0.3s ease;
}

/* Mobile optimizations */
@media (max-width: 767px) {
  .pdf-item {
    margin-bottom: 12px;
  }

  .nav-tab {
    min-height: 60px;
    padding: 6px 2px;
  }

  .icon-container {
    width: 28px;
    height: 28px;
  }
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
  .glass-effect {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--card-bg);
    border: 2px solid var(--border);
  }

  .card {
    border: 2px solid var(--border);
  }
}

/* ============ HEADER & NAVIGATION ============ */
header {
  background-color: var(--card-bg);
  border-color: var(--border);
  transition: all var(--duration-300) var(--ease-out);
  -webkit-backdrop-filter: var(--glass-backdrop);
  backdrop-filter: var(--glass-backdrop);
  padding-top: var(--safe-area-top);
  padding-left: calc(var(--safe-area-left) + var(--spacing-md));
  padding-right: calc(var(--safe-area-right) + var(--spacing-md));
}

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

nav {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

nav a {
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-lg);
  font-weight: var(--font-weight-medium);
  transition: var(--transition-all);
  white-space: nowrap;
}

nav a:hover {
  background: var(--surface);
  text-decoration: none;
}

nav a.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
}

/* ============ IMPROVED TOAST STYLES ============ */
.toast-container {
  position: fixed;
  top: 100px;
  right: var(--spacing-lg);
  z-index: var(--z-notification);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg) var(--spacing-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  animation: slideInRight var(--duration-300) var(--ease-out);
  pointer-events: auto;
  border-left: 4px solid var(--primary);
  min-width: 300px;
}

.toast.success {
  border-left-color: var(--accent);
}

.toast.error {
  border-left-color: var(--error);
}

.toast.warning {
  border-left-color: var(--warning);
}

.toast.info {
  border-left-color: var(--info);
}

.toast-icon {
  font-size: var(--font-size-xl);
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  color: var(--text);
  font-weight: var(--font-weight-medium);
}

.toast-close {
  background: transparent;
  color: var(--text-muted);
  padding: 0;
  min-width: 24px;
  min-height: 24px;
  cursor: pointer;
  flex-shrink: 0;
}

.toast-close:hover {
  color: var(--text);
  transform: none;
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(400px);
  }
}

.toast.out {
  animation: toastOut var(--duration-300) var(--ease-in) forwards;
}

@media (max-width: 768px) {
  .toast-container {
    left: var(--spacing-lg);
    right: var(--spacing-lg);
    max-width: calc(100% - var(--spacing-lg) * 2);
    bottom: var(--spacing-lg);
    top: auto;
  }

  .toast {
    min-width: auto;
  }
}

/* ============ LOADING OVERLAY ============ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-300) var(--ease-out);
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loading-overlay .loading {
  border-width: 4px;
  width: 50px;
  height: 50px;
}

/* ============ OFFLINE MESSAGE ============ */
.offline-message {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fadeIn var(--duration-300) var(--ease-out);
}

.offline-content {
  max-width: 400px;
  text-align: center;
  animation: slideInUp var(--duration-300) var(--ease-out);
}

.offline-content h2 {
  color: var(--warning);
  margin-bottom: var(--spacing-md);
}

/* ============ FOCUS & ACCESSIBILITY ============ */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

