/* ============ 暗黑主题变量（右侧内容区专用） ============ */
html[data-theme="dark"] {
  --dt-bg: #0a0b0f;
  --dt-surface: #12141a;
  --dt-surface-2: #1a1d26;
  --dt-border: #242328;
  --dt-text: #e2e8f0;
  --dt-text-strong: #6140f1;
  --dt-text-h3: #9ba2ad;
  --dt-text-p: #656c76;
  --dt-text-muted: #94a3b8;
  --dt-accent: #818cf8;
  --dt-accent-2: #c4b5fd;
  --dt-code-bg: #1e293b;
  --dt-pre-bg: #0d1117;
}

/* ============ 全局过渡（防闪烁，平滑切换） ============ */
html[data-theme] #main,
html[data-theme] .content-wrap,
html[data-theme] .content-wrap h1,
html[data-theme] .content-wrap h2,
html[data-theme] .content-wrap h3,
html[data-theme] .content-wrap h4,
html[data-theme] .content-wrap p,
html[data-theme] .content-wrap li,
html[data-theme] .content-wrap a,
html[data-theme] .content-wrap blockquote,
html[data-theme] .content-wrap blockquote p,
html[data-theme] .content-wrap code,
html[data-theme] .content-wrap pre,
html[data-theme] .content-wrap th,
html[data-theme] .content-wrap td,
html[data-theme] .content-wrap tr,
html[data-theme] .content-wrap hr,
html[data-theme] .content-wrap img,
html[data-theme] #themeSwitch {
  transition:
    transform 0.18s cubic-bezier(0.2, 0, 0, 1),
    background-color 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease,
    opacity 0.3s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
body {
  font-family:
    "PingFang SC",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Microsoft YaHei",
    sans-serif;
  background: #f0f2f5;
  color: #1e293b;
  line-height: 1.7;
}
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #1e293b;
}
::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 3px;
}

/* ============ 右侧主区域背景 ============ */
html[data-theme="dark"] #main {
  background: var(--dt-bg);
}

html[data-theme="dark"] body {
  color: var(--dt-text);
}

/* ============ 标题 ============ */
html[data-theme="dark"] .content-wrap h1 {
  color: var(--dt-text-strong);
  border-bottom-color: var(--dt-border);
}

html[data-theme="dark"] .content-wrap h2 {
  color: var(--dt-text-strong);
  border-bottom-color: var(--dt-border);
}

html[data-theme="dark"] .content-wrap h3 {
  color: var(--dt-text-h3);
}

html[data-theme="dark"] .content-wrap h4 {
  color: var(--dt-text-muted);
}

html[data-theme="dark"] .content-wrap h5 {
  color: var(--dt-text-muted);
}
/* ============ 正文、列表 ============ */
html[data-theme="dark"] .content-wrap p {
  color: var(--dt-text-p);
}

html[data-theme="dark"] .content-wrap li {
  color: var(--dt-text-p);
}

html[data-theme="dark"] .content-wrap strong {
  color: var(--dt-text-strong);
}

/* ============ 引用 blockquote ============ */
html[data-theme="dark"] .content-wrap blockquote {
  background: var(--dt-surface);
  border-left-color: #6366f1;
  color: var(--dt-text-muted);
}

html[data-theme="dark"] .content-wrap blockquote p {
  color: var(--dt-text-muted);
}

/* ============ 行内代码 ============ */
html[data-theme="dark"] .content-wrap code {
  background: var(--dt-code-bg);
  color: var(--dt-accent-2);
}

/* ============ 代码块 pre ============ */
html[data-theme="dark"] .content-wrap pre {
  background: var(--dt-pre-bg);
  border-color: var(--dt-border);
}

html[data-theme="dark"] .content-wrap pre code {
  color: var(--dt-text);
  background: transparent;
}

/* ============ 表格 ============ */
html[data-theme="dark"] .content-wrap th,
html[data-theme="dark"] .content-wrap td {
  border-color: var(--dt-border);
}

html[data-theme="dark"] .content-wrap th {
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  color: #fff;
}

html[data-theme="dark"] .content-wrap tr:nth-child(even) {
  background: var(--dt-surface);
}

/* ============ 分割线 ============ */
html[data-theme="dark"] .content-wrap hr {
  border-top-color: var(--dt-border);
}

/* ============ 图片 ============ */
html[data-theme="dark"] .content-wrap img {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* ============ 输入框（预留适配） ============ */
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background: var(--dt-surface);
  color: var(--dt-text);
  border-color: var(--dt-border);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: var(--dt-text-muted);
}

/* ============ 主题切换按钮 ============ */
#themeSwitch {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 70;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  border: none;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
  transition:
    transform 0.18s cubic-bezier(0.2, 0, 0, 1),
    background-color 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

#themeSwitch:hover {
  transform: translateY(-2px);
  border-color: rgba(129, 140, 248, 0.6);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

#themeSwitch:focus-visible {
  outline: 2px solid rgba(129, 140, 248, 0.6);
  outline-offset: 3px;
}

/* 暗黑主题下按钮外观 */
/* html[data-theme="dark"] #themeSwitch {
  color: #f1f5f9;
} */

/* 360 度转圈动画 */
@keyframes theme-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

#themeSwitch.is-spinning {
  animation: theme-spin 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ 响应式 ============ */
@media (max-width: 1023px) {
  #themeSwitch {
    top: 64px;
    right: 16px;
    width: 34px;
    height: 34px;
    min-width: 34px;
    font-size: 16px;
  }
}

/* =====================================
   字体切换按钮
   ================================== */
#fontSwitch {
  position: fixed;
  top: 176px;
  right: 24px;
  z-index: 70;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  border: none;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
  transition:
    transform 0.18s cubic-bezier(0.2, 0, 0, 1),
    background-color 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

#fontSwitch:hover {
  transform: translateY(-2px);
  border-color: rgba(129, 140, 248, 0.6);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

#fontSwitch:focus-visible {
  outline: 2px solid rgba(129, 140, 248, 0.6);
  outline-offset: 3px;
}

/* 已切换至非默认字体时的高亮 */
#fontSwitch.is-active {
  box-shadow:
    0 0 0 2px rgba(129, 140, 248, 0.6),
    0 4px 14px rgba(99, 102, 241, 0.4);
}

@media (max-width: 1023px) {
  #fontSwitch {
    top: 190px;
    right: 16px;
    width: 34px;
    height: 34px;
    min-width: 34px;
    font-size: 16px;
  }
}
/* ============ 字号调节按钮 ============ */
#fontInc,
#fontDec,
.home {
  position: fixed;
  right: 24px;
  z-index: 70;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  border: none;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
  transition:
    transform 0.18s cubic-bezier(0.2, 0, 0, 1),
    background-color 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease,
    opacity 0.3s ease;
}

#fontInc {
  top: 72px;
}
#fontDec {
  top: 124px;
}
.home {
  top: 228px;
  font-size: 18px;
  text-decoration: none;
}
#fontInc:hover,
#fontDec:hover,
.home:hover {
  transform: translateY(-2px);
  border-color: rgba(129, 140, 248, 0.6);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

#fontInc:focus-visible,
#fontDec:focus-visible {
  outline: 2px solid rgba(129, 140, 248, 0.6);
  outline-offset: 3px;
}

/* 已达上限/下限时降低透明度 */
#fontInc.is-inactive,
#fontDec.is-inactive {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

@media (max-width: 1023px) {
  #fontInc,
  #fontDec,
  .home {
    right: 16px;
    width: 34px;
    height: 34px;
    min-width: 34px;
    font-size: 16px;
  }
  #fontInc {
    top: 106px;
  }
  #fontDec {
    top: 148px;
  }
  .home {
    top: 232px;
  }
}

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: #0f172a;
  color: #cbd5e1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 50;
  border-right: 1px solid #1e293b;
}
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #1e293b;
}
.sidebar-brand {
  color: #f1f5f9;
  font-weight: 700;
  font-size: 0.95rem;
}
#sidebarNav {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #94a3b8;
  text-decoration: none;
  transition: all 0.2s;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
}
.nav-link.active {
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  color: #fff;
}
.nav-sub {
  color: #64748b;
  font-size: 0.78rem;
}
.nav-icon {
  font-size: 0.75rem;
  opacity: 0.7;
  min-width: 14px;
  text-align: center;
}
.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid #1e293b;
  font-size: 0.72rem;
  color: #475569;
}
#main {
  margin-left: 260px;
  min-height: 100vh;
  background: #f0f2f5;
}
.content-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 40px 80px;
}
.content-wrap h1 {
  font-size: 2.4rem;
  font-weight: 800;
  color: #12131d;
  margin-top: 2em;
  margin-bottom: 0.8em;
  line-height: 1.25;
  padding-bottom: 0.4em;
  border-bottom: 2px solid #e2e8f0;
}
.content-wrap > *:first-child {
  margin-top: 0 !important;
}
.content-wrap h1,
.content-wrap h2,
.content-wrap h3 {
  font-family: "Noto Serif SC", ui-serif, Georgia, serif !important;
}
.content-wrap h2 {
  font-size: 1.6rem;
  font-weight: 800;
  color: #12131d;
  margin-top: 2em;
  margin-bottom: 1em;
  line-height: 1.3;
  padding-bottom: 1em;
  border-bottom: 1px solid #e2e8f0;
}
.content-wrap h3 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1e293b;
  margin-top: 1.6em;
  margin-bottom: 1em;
}
.content-wrap h4 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-top: 1.5em;
  margin-bottom: 0.7em;
}
.content-wrap h5 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 1.4em;
  margin-bottom: 0.6em;
}
.content-wrap p {
  margin-bottom: 1.1em;
  color: #45494f;
  font-size: 1.1rem;
}

.content-wrap blockquote p,
.content-wrap li p {
  margin-bottom: 0.1em;
}

.content-wrap strong {
  color: #7654ff;
}
.content-wrap a {
  color: #0067ff;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
  font-weight: 600 !important;
}

.content-wrap a:hover {
  color: #f5007b;
  border-bottom-color: #f5007b;
}

.content-wrap ul {
  list-style: disc;
  padding-left: 1.4em;
  margin-bottom: 1.1em;
  font-size: 1.1rem;
}
.content-wrap ol {
  list-style: decimal;
  padding-left: 1.4em;
  margin-bottom: 1.1em;
  font-size: 1.1rem;
}
.content-wrap ul ul {
  list-style: circle;
  margin: 0.3em 0;
}
.content-wrap ol ol {
  list-style: lower-alpha;
  margin: 0.3em 0;
}
.content-wrap li {
  margin-bottom: 0.35em;
  color: #45494f;
  line-height: 1.7;
  font-size: 1.1rem;
}

.content-wrap blockquote ul,
.content-wrap blockquote ol,
.content-wrap blockquote li {
  margin-bottom: 0;
}

.content-wrap ul li::marker {
  color: #4f46e5; /* 小点颜色 */
  font-size: 22px; /* 还可以控制点大小 */
}

.content-wrap blockquote {
  margin: 1.2em 0;
  padding: 0.8em 1.2em;
  border-left: 4px solid #4f46e5;
  background: #fff;
  border-radius: 0 8px 8px 0;
  color: #475569;
}
.content-wrap blockquote p:last-child {
  margin-bottom: 0;
}
.content-wrap pre {
  background: #1e293b;
  border-radius: 10px;
  padding: 18px 22px;
  overflow-x: auto;
  margin-bottom: 1.2em;
  border: 1px solid #334155;
}
.content-wrap pre code {
  font-size: 0.85rem;
  line-height: 1.6;
  background: transparent;
  padding: 0;
  color: #e2e8f0;
}
.content-wrap code {
  font-size: 0.85em;
  background: #f1f5f9;
  padding: 0.15em 0.45em;
  border-radius: 4px;
  color: #7c3aed;
}
.content-wrap table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.2em;
  font-size: 0.9rem;
  border-radius: 8px;
  overflow: hidden;
}
.content-wrap th,
.content-wrap td {
  border: 1px solid #e2e8f0;
  padding: 10px 14px;
  text-align: left;
}
.content-wrap th {
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  color: #fff;
  font-weight: 700;
}
.content-wrap tr:nth-child(even) {
  background: #f8fafc;
}
.content-wrap img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 0.5em 0;
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.08);
}
.content-wrap hr {
  border: none;
  border-top: 1px solid #dadadd;
  margin: 4em 0;
}
#backToTop {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
  z-index: 60;
}
#backToTop.visible {
  opacity: 1;
  pointer-events: auto;
}
#backToTop:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.5);
}
#backToTop svg {
  width: 20px;
  height: 20px;
}
@media (max-width: 1023px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #main {
    margin-left: 0 !important;
  }
  .content-wrap {
    padding: 20px 18px 60px;
  }
  #mobileHeader {
    display: flex !important;
  }
}
#mobileHeader {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  color: #fff;
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
#mobileHeader span {
  font-weight: 700;
  font-size: 1rem;
}
#mobileMenuBtn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 8px;
  padding: 6px 8px;
  color: #fff;
  cursor: pointer;
}
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 45;
  display: none;
}
.sidebar-overlay.show {
  display: block;
}
@media (min-width: 1024px) {
  #mobileHeader {
    display: none !important;
  }
}
@media (max-width: 1023px) {
  #main {
    padding-top: 56px;
  }
}

/* ===== 视频容器 ===== */
.video-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  border-radius: 12px;
  overflow: hidden;
  margin: 16px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}
.video-wrap iframe,
.video-wrap video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}
