/* CSS Custom Properties for Theming */
:root[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --border: #e2e8f0;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
}

:root[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --border: #475569;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: all 0.3s ease;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

.hidden {
  display: none !important;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  transition: all 0.3s ease;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.logo-text {
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  line-height: 1.05;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 2rem;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
  position: relative;
}

.nav-link:hover {
  color: var(--accent);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.nav-link:hover::after {
  width: 100%;
}

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

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-secondary);
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  color: var(--accent);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

[data-theme="light"] .moon-icon,
[data-theme="dark"] .sun-icon {
  display: none;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  z-index: 1001;
}

.mobile-menu-toggle span {
  width: 25px;
  height: 3px;
  background: var(--text-primary);
  margin: 3px 0;
  transition: all 0.3s ease;
}

.mobile-menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Sidebar */
.sidebar {
  position: fixed;
  right: -320px;
  top: 0;
  bottom: 0;
  width: 320px;
  background: var(--bg-secondary);
  z-index: 99999;
  transition: right 0.3s ease;
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.sidebar.active {
  right: 0;
}

.sidebar-content {
  padding: 70px 20px 20px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.sidebar-link {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  padding: 10px 15px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.sidebar-link:hover {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
}

.sidebar-overlay.active {
  display: block;
}

/* Language Dropdown */
.lang-dropdown {
  position: relative;
}

.lang-btn {
  /* Segmented control container */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}
.lang-btn:hover { box-shadow: 0 6px 14px rgba(0,0,0,0.08); }

/* Inline language pills injected by lang.js */
.lang-btn-inline {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: color .2s ease, background-color .2s ease, transform .2s ease;
}
.lang-btn-inline:hover { color: var(--text-primary); }
.lang-btn-inline.active {
  background: linear-gradient(135deg, #60a5fa 0%, #6366f1 100%);
  color: #333;
  box-shadow: 0 6px 16px rgba(99,102,241,0.35);
}
.sidebar .lang-btn { width: 100%; justify-content: space-between; }
.sidebar .lang-btn-inline { flex: 1 1 auto; text-align: center; }

.lang-options {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 120px;
  z-index: 10;
  display: none;
}

.lang-options.show {
  display: block;
}

.lang-option {
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-option:hover {
  background: var(--bg-secondary);
  color: var(--accent);
}

/* Sidebar language block */
.sidebar-lang-mount {
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.sidebar .lang-dropdown { display: block; }
.sidebar .lang-options { right: auto; left: 0; width: 100%; }

/* User Login/Register */
.btn-login {
  padding: 8px 16px;
  background: var(--accent);
  color: #333;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
}

.btn-login:hover {
  background: var(--accent-hover);
}

.user-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
}

.dropdown {
  position: absolute;
  top: 70px;
  right: 20px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.08);
  min-width: 200px;
  z-index: 1500;
  padding: 10px 0;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

.dropdown.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.dropdown a:hover {
  background: var(--bg-secondary);
  color: var(--accent);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

/* Hero Section */
.hero {
  padding: 140px 0 80px;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  background-image: radial-gradient(60% 60% at 10% 10%, rgba(34,211,238,0.10), transparent 60%),
                    radial-gradient(60% 60% at 90% 20%, rgba(99,102,241,0.12), transparent 60%),
                    linear-gradient(120deg, rgba(34,211,238,0.06), rgba(99,102,241,0.06)),
                    linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  background-size: 200% 200%;
  animation: gradientShift 16s ease infinite;
}

.hero-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
}

.hero-title {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1.5rem;
}

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: block;
}

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

.hero-description {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* Hero Actions - Redesigned */
.hero-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 2rem;
}

.action-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  overflow: hidden;
}

.action-btn .action-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--bg-tertiary);
  transition: all 0.3s ease;
}

.action-btn .action-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
}

.action-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: var(--accent);
}

.action-btn:hover .action-icon {
  transform: scale(1.1);
  background: var(--accent);
}

.action-btn:hover .action-icon svg {
  stroke: white;
}

/* Primary Action Button */
.action-btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
}

.action-btn.primary .action-icon {
  background: rgba(255, 255, 255, 0.2);
}

.action-btn.primary .action-icon svg {
  stroke: white;
}

.action-btn.primary:hover {
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.4);
}

.action-btn.primary:hover .action-icon {
  background: rgba(255, 255, 255, 0.3);
}

/* Hot Tag */
.action-btn.hot {
  position: relative;
}

.hot-tag {
  position: absolute;
  top: 4px;
  right: 4px;
  background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(238, 90, 111, 0.4);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
  .hero-actions {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
  }
  
  .action-btn {
    padding: 0.875rem 0.75rem;
    font-size: 0.8125rem;
  }
  
  .action-btn .action-icon {
    width: 28px;
    height: 28px;
  }
  
  .action-btn .action-icon svg {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 480px) {
  .hero-actions {
    gap: 0.5rem;
  }
  
  .action-btn {
    padding: 0.75rem 0.625rem;
    font-size: 0.75rem;
  }
}

/* Old button styles - keep for backward compatibility */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 12px 24px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #333;
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(99,102,241,0.35);
}

/* Subtle glow pulse for primary button */
.btn-primary { position: relative; }
.btn-primary::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  background: radial-gradient(ellipse at center, rgba(99,102,241,0.35), rgba(34,211,238,0.0));
  filter: blur(10px);
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}
.btn-primary:hover::after { opacity: 1; }

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  transform: translateY(-2px);
}

/* Review Button - Special gradient purple style */
.btn-review {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #333;
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
  position: relative;
  overflow: hidden;
}

.btn-review::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 ease;
}

.btn-review:hover::before {
  left: 100%;
}

.btn-review:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
}

/* Reading Button - green gradient */
.btn-reading {
  background: linear-gradient(135deg, #34d399 0%, #059669 100%);
  color: #333;
  box-shadow: 0 10px 25px rgba(5, 150, 105, 0.3);
}
.btn-reading:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(5, 150, 105, 0.45);
}

/* Idiom Dictionary Button - Special pink/red gradient with animations */
.btn-idiom {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: #333;
  box-shadow: 0 10px 25px rgba(245, 87, 108, 0.3);
  position: relative;
  overflow: hidden;
  animation: pulse-soft 3s ease-in-out infinite;
}

.btn-idiom .hot-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 1.2rem;
  animation: bounce-spin 2s ease-in-out infinite;
}

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

.btn-idiom:hover::before {
  left: 100%;
}

.btn-idiom:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 18px 40px rgba(245, 87, 108, 0.5);
  animation: none;
}

.btn-idiom::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: linear-gradient(135deg, #f093fb, #f5576c, #f093fb);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-idiom:hover::after {
  opacity: 0.6;
}

@keyframes pulse-soft {
  0%, 100% {
    box-shadow: 0 10px 25px rgba(245, 87, 108, 0.3);
  }
  50% {
    box-shadow: 0 15px 35px rgba(245, 87, 108, 0.5);
  }
}

@keyframes bounce-spin {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-4px) rotate(10deg);
  }
  75% {
    transform: translateY(-2px) rotate(-10deg);
  }
}

.btn svg {
  width: 16px;
  height: 16px;
}

/* Flashcard Demo */
.hero-visual {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
}

.flashcard-demo {
  position: relative;
  width: 250px;
  height: 160px;
}

.flashcard {
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(120% 120% at 10% 10%, rgba(34,211,238,0.12), transparent 60%),
              radial-gradient(120% 120% at 90% 20%, rgba(99,102,241,0.15), transparent 60%),
              var(--bg-secondary);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.6s cubic-bezier(0.23, 1, 0.320, 1);
  border: 1px solid var(--border);
  transform-style: preserve-3d;
  perspective: 1000px;
}
.flashcard:hover { box-shadow: 0 18px 36px rgba(0,0,0,0.25); }

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-content {
  text-align: center;
  padding: 20px;
  backface-visibility: hidden;
}

.flashcard-hanzi {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
  font-family: 'Ma Shan Zheng','Zhi Mang Xing','Long Cang','ZCOOL XiaoWei', serif;
  letter-spacing: 1px;
  text-shadow: 0 2px 12px rgba(59,130,246,0.35);
}

.flashcard-pinyin {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.flashcard-meaning {
  font-size: 1rem;
  color: var(--text-primary);
  transform: rotateY(180deg);
  position: absolute;
  backface-visibility: hidden;
}

/* Idiom card styling */
.flashcard-idiom {
  background: radial-gradient(120% 120% at 10% 10%, rgba(255,193,7,0.12), transparent 60%),
              radial-gradient(120% 120% at 90% 20%, rgba(255,87,34,0.15), transparent 60%),
              var(--bg-secondary);
  border: 1px solid rgba(255,193,7,0.3);
}

.flashcard-idiom:hover {
  box-shadow: 0 18px 36px rgba(255,193,7,0.25);
  border-color: rgba(255,193,7,0.5);
}

.flashcard-type {
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(45deg, #ffc107, #ff5722);
  color: #333;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(255,193,7,0.4);
}

.flashcard-idiom .flashcard-hanzi {
  color: #ff8f00;
  text-shadow: 0 2px 12px rgba(255,143,0,0.35);
}

/* Special dedicated idiom flashcard */
.flashcard-idiom-special {
  position: relative;
  width: 280px;
  height: 180px;
  margin-left: 2rem;
  animation: float 3s ease-in-out infinite;
}

.flashcard-idiom-special .flashcard {
  width: 100%;
  height: 100%;
  background: radial-gradient(120% 120% at 10% 10%, rgba(255,193,7,0.15), transparent 60%),
              radial-gradient(120% 120% at 90% 20%, rgba(255,87,34,0.18), transparent 60%),
              linear-gradient(135deg, #fff8e1 0%, #ffe0b2 100%);
  border: 2px solid #ffc107;
  box-shadow: 0 15px 35px rgba(255,193,7,0.3),
              0 5px 15px rgba(0,0,0,0.12);
}

.flashcard-idiom-special .flashcard:hover {
  transform: translateY(-5px) rotateY(5deg);
  box-shadow: 0 20px 40px rgba(255,193,7,0.4),
              0 8px 20px rgba(0,0,0,0.15);
}

.flashcard-crown {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  z-index: 10;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  animation: crownGlow 2s ease-in-out infinite alternate;
}

.flashcard-hot-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(45deg, #ff6b35, #f7931e);
  color: #333;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(255,107,53,0.5);
  animation: hotPulse 1.5s ease-in-out infinite;
  letter-spacing: 0.5px;
}

.flashcard-idiom-special .flashcard-hanzi {
  font-size: 2.2rem;
  color: #e65100;
  text-shadow: 0 2px 8px rgba(230,81,0,0.4);
  margin-bottom: 8px;
}

.flashcard-idiom-special .flashcard-pinyin {
  font-size: 1rem;
  color: #bf360c;
  margin-bottom: 8px;
}

.flashcard-idiom-special .flashcard-type {
  background: linear-gradient(45deg, #ff8f00, #ff6f00);
  top: 8px;
  right: 8px;
  font-size: 0.7rem;
  padding: 3px 8px;
}

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

@keyframes crownGlow {
  0% {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  }
  100% {
    filter: drop-shadow(0 4px 8px rgba(255,215,0,0.6));
  }
}

@keyframes hotPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(255,107,53,0.5);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(255,107,53,0.7);
  }
}

/* Latest Articles Section */
.latest-articles {
  margin-top: clamp(2rem, 5vw, 3.5rem);
}

.latest-articles .container {
  position: relative;
  padding: clamp(1.75rem, 4vw, 3rem);
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(59, 130, 246, 0.02));
  box-shadow: var(--shadow);
}

.latest-articles__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: clamp(1.5rem, 3vw, 2rem);
}

.latest-articles__intro {
  max-width: 520px;
}

.latest-articles__eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.latest-articles__title {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  line-height: 1.3;
  font-weight: 700;
  color: var(--text-primary);
}

.latest-articles__link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.latest-articles__link:hover {
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(59, 130, 246, 0.5);
  transform: translateY(-2px);
}

.latest-articles__body {
  display: flex;
  align-items: stretch;
  gap: clamp(1rem, 2vw, 1.5rem);
}

.latest-articles__viewport {
  position: relative;
  flex: 1;
  overflow: hidden;
  min-height: clamp(220px, 28vw, 260px);
}

.latest-articles__track {
  display: flex;
  gap: clamp(1rem, 2vw, 1.5rem);
  transform: translateX(0);
  transition: transform 0.6s ease;
  will-change: transform;
}

.latest-articles__item {
  flex: 0 0 var(--item-width, 100%);
  min-width: 0;
  display: flex;
}

.latest-articles__card {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.latest-articles__card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.latest-articles__image {
  position: relative;
  padding-top: 60%;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.latest-articles__image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.latest-articles__card:hover .latest-articles__image img {
  transform: scale(1.05);
}

.latest-articles__content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem 1.4rem 1.5rem;
  height: 100%;
}

.latest-articles__tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.latest-articles__item-title {
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  line-height: 1.4;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.latest-articles__excerpt {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
  flex: 1;
}

.latest-articles__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.latest-articles__meta::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.6);
}

.latest-articles__nav {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: var(--bg-primary);
  color: var(--text-primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1);
}

.latest-articles__nav:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.5);
  color: var(--accent);
}

.latest-articles__nav:disabled,
.latest-articles__nav.is-hidden {
  opacity: 0.35;
  pointer-events: none;
}

.latest-articles__status {
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
}

.latest-articles__status.is-hidden {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .latest-articles__track {
    transition-duration: 0.001ms;
  }
  .latest-articles__card,
  .latest-articles__link,
  .latest-articles__nav {
    transition-duration: 0.001ms;
    animation-duration: 0.001ms !important;
  }
}

@media (max-width: 900px) {
  .latest-articles .container {
    padding: clamp(1.5rem, 5vw, 2.25rem);
  }
}

@media (max-width: 768px) {
  .latest-articles__header {
    flex-direction: column;
    align-items: flex-start;
  }
  .latest-articles__body {
    gap: 0.75rem;
  }
  .latest-articles__title {
    font-size: clamp(1.35rem, 5vw, 1.8rem);
  }
}

@media (max-width: 640px) {
  .latest-articles__nav {
    display: none;
  }
  .latest-articles .container {
    padding: clamp(1.25rem, 6vw, 2rem);
  }
  .latest-articles__viewport {
    min-height: 240px;
  }
}

/* Feature Cards Carousel */
.feature-cards {
  padding: 60px 0;
  background: var(--bg-primary);
}

.carousel-container {
  position: relative;
  margin: 40px auto;
  max-width: 900px;
  height: 380px; /* taller on desktop to avoid clipping content */
  overflow: hidden;
}

.carousel-track {
  position: relative;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.5s ease-out;
}

.carousel-card {
  position: absolute;
  width: 400px;
  height: 320px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 25px 55px rgba(0,0,0,.12);
  cursor: pointer;
  transition: all 0.5s ease;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
}

.carousel-card.active {
  z-index: 10;
  box-shadow: 0 22px 48px rgba(0,0,0,0.22);
}

.card-bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  z-index: 1;
  cursor: pointer;
}

.card-content {
  position: relative;
  z-index: 2;
  padding: 24px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.card-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #333;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.card-description {
  font-size: 1rem;
  color: #333;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.card-ribbon {
  position: absolute;
  top: 20px;
  right: -30px;
  background: #ff3b30;
  color: #333;
  padding: 5px 30px;
  transform: rotate(45deg);
  z-index: 5;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  border-radius: 6px;
}

.hot-star-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: linear-gradient(45deg, #ff9500, #ff3b30);
  color: #333;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: bold;
  z-index: 5;
  box-shadow: 0 2px 10px rgba(255, 59, 48, 0.4);
  animation: pulse 2s infinite;
}

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

.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
}

.carousel-nav:hover {
  background: var(--accent);
  color: #333;
}

.carousel-prev {
  left: 10px;
}

.carousel-next {
  right: 10px;
}

/* Theme variants to match index.css visual spec */
.theme-0 .card-title { color: #007f9e; }
.theme-0 .card-description { color: #333; text-shadow: 1px 1px 1px #222; font-weight: 600; }
.theme-0 .card-bg-canvas {
  background: radial-gradient(
    circle at 40% 40%,
    rgba(0, 176, 255, 0.35),
    rgba(153, 102, 255, 0.15),
    transparent
  );
}
.carousel-card.theme-0.active {
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.6), 0 0 60px rgba(76, 175, 80, 0.25);
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.theme-1 .card-title { color: #4AA8F2; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,0.25); }
.theme-1 .card-description { color: rgba(255,255,255,0.9); font-weight: 500; text-shadow: 0 0 4px rgba(0,0,0,0.2); }
.theme-1 .card-bg-canvas {
  background: radial-gradient(circle at 50% 50%, #A9D1F7, #CCC96A, transparent);
}
.carousel-card.theme-1.active {
  box-shadow: 0 0 20px #4AA8F2, 0 0 40px rgba(74, 168, 242, 0.4);
  border: 1px solid rgba(74, 168, 242, 0.5);
}

/* Features Section */
.features {
  padding: 80px 0;
  background: var(--bg-secondary);
}

.section-title {
  text-align: center;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 3rem;
  color: var(--text-primary);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
}

.feature-card {
  background: var(--bg-primary);
  padding: 2rem;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

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

.feature-icon {
  width: 60px;
  height: 60px;
  background: var(--gradient);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.feature-icon svg {
  width: 24px;
  height: 24px;
  stroke: white;
}

.feature-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

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

/* Stats Section */
.stats {
  padding: 60px 0;
  background: var(--bg-primary);
}

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

.stat-item {
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .6s ease, transform .6s ease;
}
.stat-item.visible { opacity: 1; transform: translateY(0); }

.stat-number {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 1rem;
  color: var(--text-secondary);
}

/* Footer */
.footer {
  background: var(--bg-secondary);
  padding: 40px 0 20px;
  border-top: 1px solid var(--border);
}

.footer-content {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 3rem;
  margin-bottom: 2rem;
}

.footer-brand p {
  color: var(--text-secondary);
  margin: 1rem 0;
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 2rem;
}

.footer-column h4 {
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.footer-column a {
  display: block;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 0.5rem;
  transition: color 0.3s ease;
}

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

.footer-bottom {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #333;
  transition: all 0.3s ease;
}

.social-links a:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.dmca-badge {
  display: block;
  margin-top: 1rem;
}

/* Notification Area */
#notificationArea {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
}

.toast {
  background: rgba(0, 0, 0, 0.85);
  color: #333;
  padding: 10px 15px;
  border-radius: 8px;
  margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: fadeIn 0.3s ease;
}

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

/* Responsive Design */
@media (max-width: 992px) {
  .hero-title {
    font-size: 2.5rem;
  }
  
  .footer-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .nav {
    display: none;
  }
  
  .mobile-menu-toggle {
    display: flex;
  }
  
  .hero-content {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    text-align: center;
  }
  /* Hide user toggle on mobile */
  .user-toggle { display: none !important; }
  
  .hero-title {
    font-size: 2.2rem;
  }
  
  .hero-actions {
    justify-content: center;
  }
  
  .features-grid {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .btn-login {
    display: none;
  }
  
  /* Show login buttons in sidebar for mobile */
  .sidebar .btn-login {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    text-align: center;
  }
  
  .carousel-card {
    width: 320px;
    height: 320px; /* same height as desktop */
  }
  .carousel-container { height: 380px !important; }
  
  .hero-visual {
    flex-direction: column;
    gap: 2rem;
  }
  
  .flashcard-idiom-special {
    margin-left: 0;
    width: 250px;
    height: 160px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 15px;
  }
  
  .hero {
    padding: 110px 0 50px;
  }
  
  .hero-title {
    font-size: 1.8rem;
  }
  
  .hero-description {
    font-size: 1rem;
  }
  
  .hero-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .flashcard-demo {
    width: 220px;
    height: 140px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .carousel-card {
    width: 280px;
    height: 320px; /* same height as desktop */
  }
  .carousel-container { height: 380px !important; }
  
  .section-title {
    font-size: 2rem;
  }
  
  .flashcard-idiom-special {
    width: 220px;
    height: 140px;
  }
  
  .flashcard-idiom-special .flashcard-hanzi {
    font-size: 1.8rem;
  }
  
  .flashcard-crown {
    font-size: 1.5rem;
    top: -12px;
  }
}

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

.feature-card {
  animation: fadeInUp 0.6s ease forwards;
}

.feature-card:nth-child(1) { animation-delay: 0.1s; }
.feature-card:nth-child(2) { animation-delay: 0.2s; }
.feature-card:nth-child(3) { animation-delay: 0.3s; }
.feature-card:nth-child(4) { animation-delay: 0.4s; }
@import url('https://fonts.googleapis.com/css2?family=Long+Cang&family=Ma+Shan+Zheng&family=Zhi+Mang+Xing&display=swap');

/* Nav Overrides: remove shadows and solid backgrounds from nav bar */
.header .nav {
  box-shadow: none !important;
  background: transparent !important;
  border: none !important;
}
.header .nav .nav-menu,
.header .nav .menu-item,
.header .nav .menu-link,
.header .header-actions,
.header .lang-dropdown,
.header .lang-btn {
  box-shadow: none !important;
}
