/* top.css */
.top-div {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 20px;
}

.top {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  gap: 10px;
  margin: auto 0 20px;
}

.top-text {
  display: block;
}

.top-div h2 {
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  color: var(--color-text-primary);
  text-shadow: 0 1px 4px var(--color-text-shadow);
}

/* 汉堡按钮 */
.hamburger-btn {
  position: absolute;
  top: 50%;
  right: 15px;
  display: none;
  padding: 6px 10px;
  font-size: 24px;
  color: var(--color-text-primary);
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transform: translateY(-50%);
  transition: background 0.2s;
}

.hamburger-btn:hover {
  background: var(--color-bg-hover-strong);
}

/* 白天 / 黑夜开关 */
.theme-switch {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.theme-switch:focus-visible {
  outline: 2px solid var(--color-border-strong);
  outline-offset: 3px;
}

.theme-switch-track {
  position: relative;
  display: block;
  width: 58px;
  height: 28px;
  background: var(--color-bg-hover-strong);
  border: 1px solid var(--color-border-light);
  border-radius: 999px;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.theme-switch:hover .theme-switch-track {
  background: var(--color-bg-active);
  border-color: var(--color-border-medium);
}

.theme-switch-icon {
  position: absolute;
  top: 50%;
  font-size: 12px;
  color: var(--color-text-muted);
  opacity: 0.55;
  transform: translateY(-50%);
  transition: color 0.25s ease, opacity 0.25s ease;
}

.theme-switch-sun {
  left: 7px;
}

.theme-switch-moon {
  right: 7px;
}

/* 滑块 = 页面主文字色（浅色下是深靛蓝，暗色下是冷白），自动跟着主题反转 */
.theme-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: var(--color-text-primary);
  border-radius: 50%;
  box-shadow: 0 1px 3px var(--color-shadow-light);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 滑块移动：浅色时压住太阳，暗色时压住月亮 */
html[data-theme='dark'] .theme-switch-knob {
  transform: translateX(30px);
}

/* 被滑块盖住的那个图标反相，露出底色 */
html:not([data-theme='dark']) .theme-switch-sun,
html[data-theme='dark'] .theme-switch-moon {
  color: var(--color-bg-light-gray);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .theme-switch-track,
  .theme-switch-icon,
  .theme-switch-knob {
    transition: none;
  }
}

.sidebar {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 768px) {
  .hamburger-btn {
    display: block;
  }

  /* 给绝对定位的汉堡按钮让位 */
  .theme-switch {
    margin-right: 46px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    width: 80%;
    max-width: 280px;
    height: 90vh;
    margin: 5vh 0;
    padding: 20px;
    overflow-y: auto;
    background: var(--color-bg-elevated);
    border-right: 1px solid var(--color-border-subtle);
    box-shadow: 2px 0 12px var(--color-shadow-medium);
    scrollbar-width: none;
    -ms-overflow-style: none;
    transform: translateX(-110%);
    transition: transform 0.3s cubic-bezier(0.9, 0, 0.2, 1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
    display: none;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

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

  .sidebar .info-profile img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 85%;
    max-width: 260px;
  }
}