:root {
  --primary-color: #a2828d;
  --secondary-color: #c2a2ad;
  --background-color: #f8f6fa;
  --code-background: #f8f9fa;
  --text-color: #2d2d2d;
  --border-radius: 6px;
  --button-gradient: linear-gradient(45deg, #a2828d,  #c7879d);
  --button-hover-gradient: linear-gradient(45deg, #8465c3, #a98eda);
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.3;
  color: var(--text-color);
  background-color: var(--background-color);
  margin: 0;
  padding: 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem;
}

header {
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  text-align: center;
  color: white;
  border-radius: var(--border-radius);
}

header h1 {
  text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
  margin: 0;
  font-size: 1.75rem;
}

.exercise {
  position: relative;
  background-color: white;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--border-radius);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: all 0.3s ease-in-out;
  transform-origin: center;
  border: 1px solid rgba(132, 101, 195, 0.1);
  display: none;
}

.exercise:hover {
  transform: translateY(-2px) scale(1.005);
  box-shadow: 0 4px 12px rgba(132, 101, 195, 0.15);
}

.exercise::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.exercise.active {
  display: block;
}

h2 {
  color: var(--primary-color);
  border-bottom: 2px solid var(--secondary-color);
  padding-bottom: 0.15rem;
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.3rem;
}

h3 {
  color: var(--secondary-color);
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
}

h4 {
  margin: 0.25rem 0;
  font-size: 1rem;
}

.math {
  overflow-x: auto;
  padding: 0.5rem;
  background: linear-gradient(45deg, var(--code-background), white);
  border: 1px solid rgba(102, 51, 153, 0.1);
  border-radius: var(--border-radius);
  margin: 0.25rem 0;
}

.matlab-code {
  position: relative;
  background: #f8f9fa;
  padding: 1.25rem;
  border-radius: var(--border-radius);
  margin: 0.5rem 0;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
  overflow-x: auto;
  transition: all 0.3s ease;
}

.matlab-code:hover {
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.1);
}

.matlab-code::before {
  content: 'MATLAB';
  position: absolute;
  top: 0;
  right: 0;
  background: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 0 var(--border-radius) 0 var(--border-radius);
  opacity: 0.8;
}

.matlab-code pre {
  margin: 0;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.95rem;
  line-height: 1.4;
}

.matlab-code .comment {
  color: #228B22; 
}

.matlab-code .keyword {
  color: #0000FF; 
  font-weight: bold;
}

.matlab-code .function {
  color: #A020F0; 
}

.matlab-code .string {
  color: #B22222; 
}

.matlab-code .number {
  color: #B8860B; 
}

.matlab-code .operator {
  color: #000000; 
}

.result {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: linear-gradient(45deg, white, var(--background-color));
  border: 1px solid rgba(102, 51, 153, 0.1);
  border-radius: var(--border-radius);
}

.problem, .solution {
  background: linear-gradient(to right, white, var(--background-color));
  padding: 1rem;
  border-radius: var(--border-radius);
  margin: 1rem 0;
  border-left: 3px solid var(--primary-color);
  transition: all 0.2s ease;
}

.problem:hover, .solution:hover {
  box-shadow: 0 2px 8px rgba(132, 101, 195, 0.1);
  transform: translateX(2px);
}

p {
  margin: 0.25rem 0;
}

.add-button {
  display: block;
  margin: 1rem auto;
  padding: 0.5rem 1rem;
  background: var(--button-gradient);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  opacity: 0.9;
}

.add-button:hover {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  background: var(--button-hover-gradient);
}

.nav-menu {
  background-color: rgba(132, 101, 195, 0.1);
  padding: 0.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(132, 101, 195, 0.2);
  transition: all 0.3s ease;
  transform-origin: top;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.35rem;
  padding: 0.35rem;
}

.nav-button {
  position: relative;
  overflow: hidden;
  z-index: 1;
  background: var(--button-gradient);
  color: white;
  border: none;
  padding: 0.35rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  font-size: 0.85rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  opacity: 0.9;
}

.nav-button::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: 0.5s;
  z-index: -1;
}

.nav-button:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0,0,0,0.15);
  background: var(--button-hover-gradient);
}

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

.nav-button.active {
  background: var(--button-hover-gradient);
  transform: translateY(0);
  opacity: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.nav-menu.reveal {
  animation: slideDown 0.5s ease-out;
}

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

.matlab-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--button-gradient);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  cursor: pointer;
  font-size: 1rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: pulse 2s infinite;
}

.matlab-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 12px rgba(0,0,0,0.25);
  background: var(--button-hover-gradient);
}

.matlab-button svg {
  width: 24px;
  height: 24px;
  fill: white;
}

ul, ol {
  margin: 0.25rem 0;
  padding-left: 1.5rem;
}

li {
  margin: 0.15rem 0;
}

code {
  background-color: var(--code-background);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9em;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
  }
}

.hidden {
  display: none !important;
}

.show-more-button {
  display: block;
  margin: 1rem auto;
  padding: 0.75rem 1.5rem;
  background: var(--button-gradient);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s ease;
  box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

.show-more-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 12px rgba(0,0,0,0.25);
  background: var(--button-hover-gradient);
}

@media (max-width: 768px) {
  .container {
    padding: 0.25rem;
  }
  
  .exercise {
    padding: 0.5rem;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  .nav-container {
    padding: 0.15rem;
  }
  
  .nav-button {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --background-color: #1a1a1a;
    --text-color: #e0e0e0;
    --code-background: #2d2d2d;
  }

  .exercise, .problem, .solution {
    background-color: #2d2d2d;
    border-color: rgba(132, 101, 195, 0.2);
  }

  .matlab-code {
    background: #1a1a1a;
  }

  .matlab-code .comment {
    color: #66ff66;
  }
}

.loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.loading::after {
  content: '';
  width: 50px;
  height: 50px;
  border: 5px solid var(--primary-color);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}