body {
  font-family: 'Inter', sans-serif;
  padding-top: 70px;
  max-width: 900px;
  margin: auto;
  background-color: #f5f5f5;
}

header {
  box-sizing: border-box;
  background-color: #18398A;
  padding: 10px 20px;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.logo {
  flex: 0 0 auto;
  height: 40px;
}

.title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  min-width: 0;
}

.title-group h1 {
  font-size: 18px;
  margin: 0;
  color: white;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.back-btn-header {
  flex: 0 0 auto;
  background-color: #fff;
  color: #18398A;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 14px;
  text-decoration: none;
  font-weight: bold;
  white-space: nowrap;
}

.back-btn-header:hover {
  background-color: #e0e0e0;
}

nav {
  position: absolute;
  top: 60px;
  left: 10px;
  background-color: #18398A;
  border-radius: 8px;
  padding: 10px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: none;
}

.menu-btn:hover ~ nav,
nav:hover {
  display: block;
}

.menu-btn {
  cursor: pointer;
  font-size: 24px;
  background: none;
  border: none;
  color: white;
  margin-right: 10px;
}

.menu-list,
.submenu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu-list li {
  position: relative;
}

.menu-list a {
  display: block;
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  text-decoration: none;
}

.menu-list a:hover {
  background-color: #3366cc;
}

.dropdown:hover .submenu {
  display: block;
}

.submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  background-color: #0e2a6d;
  border-radius: 5px;
  min-width: 220px;
}

main h1 {
  font-weight: 600;
  color: #18398A;
  margin-bottom: 10px;
}

.problem {
  margin-bottom: 40px;
  padding: 25px;
  border: 1px solid #ccc;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.problem h3 {
  background-color: #fff9c4;
  color: #4a4a4a;
  padding: 14px 20px;
  border-left: 8px solid #fbc02d;
  border-radius: 6px;
  font-size: 20px;
  font-weight: 600;
  font-family: 'Comic Sans MS', 'Patrick Hand', 'Segoe UI', cursive;
  box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
}

.solution {
  display: none;
  margin: 20px -25px 0 -25px;
  padding: 20px 25px;
  background-color: #eef2ff;
  border-left: 5px solid #18398A;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

button {
  background-color: #2962ff;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
}

button:hover {
  background-color: #1c4ed8;
}

.math-box {
  border: 2px solid #18398A;
  padding: 14px 18px;
  background-color: #f0f4ff;
  border-radius: 6px;
  margin: 10px 0;
  display: block;
  font-size: 18px;
  overflow-x: auto;
  max-width: 100%;
  box-sizing: border-box;
}

p,
ol,
li {
  font-family: 'Inter', sans-serif;
  font-size: 17px;
  line-height: 1.75;
  color: #2c2c2c;
  margin-bottom: 14px;
}

ol {
  padding-left: 24px;
}

.note-box {
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
  font-size: 0.95rem;
  border-left: 4px solid #f59e0b;
  background-color: #fef3c7;
  color: #78350f;
}

body.dark-mode {
  background-color: #121212;
  color: #f0f0f0;
}

body.dark-mode header {
  background-color: #1f1f1f;
}

body.dark-mode p,
body.dark-mode li,
body.dark-mode ol,
body.dark-mode .problem h3,
body.dark-mode .math-box,
body.dark-mode .solution,
body.dark-mode .problem {
  color: #f0f0f0;
}

body.dark-mode .problem {
  background-color: #1e1e1e;
  border-color: #333;
}

body.dark-mode .solution {
  background-color: #2a2a2a;
  border-left-color: #90caf9;
}

body.dark-mode .math-box {
  background-color: #2b2b2b;
  border-color: #90caf9;
  color: #e0e0e0;
}

body.dark-mode button {
  background-color: #3949ab;
}

body.dark-mode .problem h3 {
  background-color: #333;
  border-left-color: #ffeb3b;
  color: #fff9c4;
}

body.dark-mode .note-box {
  background-color: #2e2a1f;
  color: #fef9c3;
  border-color: #facc15;
}

body.dark-mode .mjx-mrow {
  color: #ffffff !important;
}

.dark-mode-toggle {
  flex: 0 0 auto;
  margin-left: auto;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.switch input {
  display: none;
}

.slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 34px;
  transition: 0.4s;
  cursor: pointer;
}

.slider:before {
  content: '🌙';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border-radius: 50%;
  transition: 0.4s;
}

.switch input:checked ~ .slider {
  background-color: #4d90fe;
}

.switch input:checked ~ .slider:before {
  transform: translateX(24px);
  content: '☀️';
}

#problemNav {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 9999;
  font-size: 14px;
  max-width: 280px;
}

#toggleNavBtn {
  background-color: #18398A;
  color: white;
  border: none;
  border-radius: 50px;
  padding: 10px 16px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#navContent {
  display: none;
  background: #fff;
  border: 2px solid #18398A;
  border-radius: 10px;
  padding: 12px 16px;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#problemList {
  list-style: none;
  padding-left: 0;
  margin-top: 10px;
}

@media screen and (max-width: 768px) {
  header {
    padding: 10px 12px;
  }

  .title-group {
    flex: 1 1 auto;
    gap: 8px;
  }

  .title-group h1 {
    font-size: 15px;
  }

  .back-btn-header {
    padding: 4px 8px;
    font-size: 12px;
  }
}
