:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: rgba(30, 41, 59, 0.8);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-pink: #ec4899;
  --accent-green: #10b981;
  --accent-purple: #8b5cf6;
  --border-color: rgba(148, 163, 184, 0.15);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(59, 130, 246, 0.12) 0%, transparent 40%),
    radial-gradient(ellipse at 80% 80%, rgba(6, 182, 212, 0.12) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 50%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 10% 90%, rgba(236, 72, 153, 0.08) 0%, transparent 35%);
  pointer-events: none;
  z-index: -2;
  animation: bgPulse 8s ease-in-out infinite;
}

body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: -1;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

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

.global-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.particle-dot {
  position: absolute;
  width: 4px;
  height: 4px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.6) 0%, transparent 70%);
  border-radius: 50%;
  animation: particleFloat linear infinite;
  opacity: 0;
}

.particle-dot:nth-child(1) {
  left: 10%;
  width: 3px;
  height: 3px;
  animation-duration: 15s;
  animation-delay: 0s;
}

.particle-dot:nth-child(2) {
  left: 25%;
  width: 5px;
  height: 5px;
  animation-duration: 20s;
  animation-delay: -3s;
}

.particle-dot:nth-child(3) {
  left: 45%;
  width: 2px;
  height: 2px;
  animation-duration: 12s;
  animation-delay: -5s;
}

.particle-dot:nth-child(4) {
  left: 65%;
  width: 4px;
  height: 4px;
  animation-duration: 18s;
  animation-delay: -8s;
}

.particle-dot:nth-child(5) {
  left: 80%;
  width: 6px;
  height: 6px;
  animation-duration: 22s;
  animation-delay: -2s;
}

.particle-dot:nth-child(6) {
  left: 90%;
  width: 3px;
  height: 3px;
  animation-duration: 16s;
  animation-delay: -10s;
}

.particle-dot:nth-child(7) {
  left: 15%;
  width: 4px;
  height: 4px;
  animation-duration: 19s;
  animation-delay: -6s;
}

.particle-dot:nth-child(8) {
  left: 35%;
  width: 2px;
  height: 2px;
  animation-duration: 14s;
  animation-delay: -12s;
}

.particle-dot:nth-child(9) {
  left: 55%;
  width: 5px;
  height: 5px;
  animation-duration: 21s;
  animation-delay: -4s;
}

.particle-dot:nth-child(10) {
  left: 75%;
  width: 3px;
  height: 3px;
  animation-duration: 17s;
  animation-delay: -9s;
}

@keyframes particleFloat {
  0% {
    transform: translateY(100vh) scale(0.5);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100px) scale(1);
    opacity: 0;
  }
}

code, pre, .mono {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--accent-cyan);
}

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: relative;
}

.navbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-blue), var(--accent-cyan), var(--accent-purple), transparent);
  opacity: 0.5;
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-brand-icon {
  width: 32px;
  height: 32px;
}

.navbar-links {
  display: flex;
  gap: 8px;
  margin-left: 40px;
}

.navbar-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
}

.navbar-link:hover,
.navbar-link.active {
  color: var(--text-primary);
  background: rgba(59, 130, 246, 0.1);
}

.main-content {
  margin-top: 64px;
  min-height: calc(100vh - 64px);
}

.page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 32px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-blue), transparent);
  opacity: 0;
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 
    0 8px 30px rgba(59, 130, 246, 0.2),
    0 0 40px rgba(59, 130, 246, 0.1),
    inset 0 1px 0 rgba(59, 130, 246, 0.1);
  transform: translateY(-4px);
}

.card:hover::before {
  opacity: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: white;
  position: relative;
  overflow: hidden;
}

.btn-primary::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-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 8px 24px rgba(59, 130, 246, 0.5),
    0 0 40px rgba(6, 182, 212, 0.2);
}

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

.btn-secondary:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--accent-blue);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 24px;
}

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

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

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

.flex {
  display: flex;
}

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

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

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 8px;
}

.gap-4 {
  gap: 16px;
}

.gap-6 {
  gap: 24px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-4 {
  margin-top: 16px;
}

.mt-6 {
  margin-top: 24px;
}

.mt-8 {
  margin-top: 32px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mb-6 {
  margin-bottom: 24px;
}

.mb-8 {
  margin-bottom: 32px;
}

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

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

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

.text-amber {
  color: var(--accent-amber);
}

.text-cyan {
  color: var(--accent-cyan);
}

.text-green {
  color: var(--accent-green);
}

.text-pink {
  color: var(--accent-pink);
}

.bg-amber {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
}

.bg-green {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.bg-blue {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.bg-pink {
  background: rgba(236, 72, 153, 0.15);
  color: var(--accent-pink);
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.chapter-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px;
}

.sidebar {
  position: sticky;
  top: 88px;
  height: fit-content;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
}

.sidebar-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding: 0 12px;
}

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

.sidebar-link {
  display: block;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: var(--transition);
  cursor: pointer;
}

.sidebar-link:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(6, 182, 212, 0.2));
  color: var(--text-primary);
  font-weight: 600;
  border-left: 3px solid var(--accent-blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  position: relative;
  box-shadow: inset 0 0 20px rgba(59, 130, 246, 0.1);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: linear-gradient(180deg, var(--accent-blue), var(--accent-cyan));
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 10px var(--accent-blue);
}

.sidebar-link.sub {
  padding-left: 32px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.sidebar-link.sub:hover {
  color: var(--accent-cyan);
}

.sidebar-link.sub.active {
  color: var(--accent-cyan);
  font-weight: 600;
  background: rgba(6, 182, 212, 0.1);
}

.sidebar-subgroup {
  padding-left: 20px;
  display: none;
}

.sidebar-subgroup.open {
  display: block;
}

.sidebar-sub-link {
  font-size: 0.85rem;
  padding: 8px 12px;
  color: var(--text-muted);
}

.content-area {
  min-width: 0;
}

.knowledge-section {
  margin-bottom: 48px;
  scroll-margin-top: 80px;
}

.knowledge-section h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-color);
  position: relative;
}

.knowledge-section h2::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 80px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  border-radius: 2px;
}

.knowledge-section h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 24px 0 12px;
  color: var(--accent-cyan);
}

.knowledge-section p {
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.8;
}

.knowledge-section ul,
.knowledge-section ol {
  color: var(--text-secondary);
  margin-left: 20px;
  margin-bottom: 12px;
  line-height: 1.8;
}

.knowledge-section li {
  margin-bottom: 6px;
}

.knowledge-section strong {
  color: var(--text-primary);
  font-weight: 600;
}

.formula-box {
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 16px 0;
  text-align: center;
}

.formula-box .formula {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  color: var(--accent-cyan);
  letter-spacing: 1px;
}

.tip-box {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 16px 0;
  display: flex;
  gap: 12px;
}

.tip-box-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.tip-box-content {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.tip-box-content strong {
  color: var(--accent-amber);
  display: block;
  margin-bottom: 4px;
}

.animation-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 16px 0;
  position: relative;
  transition: var(--transition);
}

.animation-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-blue), var(--accent-cyan), transparent);
  opacity: 0.6;
}

.animation-container:hover {
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 
    0 0 30px rgba(59, 130, 246, 0.15),
    0 4px 20px rgba(0, 0, 0, 0.3);
}

.animation-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.08), rgba(6, 182, 212, 0.08), rgba(139, 92, 246, 0.05));
  position: relative;
}

.animation-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 18px;
  right: 18px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan), transparent);
  opacity: 0.4;
}

.animation-title {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.animation-title::before {
  content: '';
  width: 4px;
  height: 18px;
  background: linear-gradient(180deg, var(--accent-blue), var(--accent-cyan));
  border-radius: 2px;
}

.animation-canvas-wrap {
  position: relative;
  background: var(--bg-primary);
  overflow: hidden;
}

.animation-canvas {
  width: 100%;
  display: block;
}

.animation-controls {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.2);
}

.animation-description {
  padding: 12px 18px;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.control-group select,
.control-group input[type="range"],
.control-group input[type="number"] {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.control-group select:focus,
.control-group input:focus {
  border-color: var(--accent-blue);
}

.control-group input[type="range"] {
  padding: 0;
  height: 4px;
  cursor: pointer;
}

.speed-indicator {
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--accent-cyan);
  font-family: 'JetBrains Mono', monospace;
  min-width: 50px;
  text-align: center;
}

.step-indicator {
  padding: 8px 16px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--accent-blue);
  margin-left: auto;
}

.table-container {
  overflow-x: auto;
  margin: 16px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: rgba(59, 130, 246, 0.1);
  color: var(--text-primary);
  font-weight: 600;
}

td {
  color: var(--text-secondary);
}

tr:hover td {
  background: rgba(59, 130, 246, 0.05);
}

.footer {
  margin-top: 64px;
  padding: 32px 24px;
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media (max-width: 1024px) {
  .chapter-layout {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    position: static;
    max-height: none;
  }
  
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .navbar-links {
    display: none;
  }
  
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }
  
  .section-title {
    font-size: 1.5rem;
  }
}

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

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 10px rgba(59, 130, 246, 0.3); }
  50% { box-shadow: 0 0 30px rgba(59, 130, 246, 0.6); }
}

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

.animate-float {
  animation: float 4s ease-in-out infinite;
}

.animate-pulse-glow {
  animation: pulse-glow 2s ease-in-out infinite;
}
