:root {
  --sidebar-width: 350px;
}
/* Avoid animation while dragging */
.sidebar {
  transition: none !important;
}
.no-select {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}
/* Sidebar toggle Button Styles */
.sidebar-toggle {
  position: fixed !important;
  top: 10px;
  left: 10px;
  z-index: 9999;
  margin: 0;
}
.sidebar-toggle-button {
  width: 32px;
  height: 32px;
}
.sidebar .sidebar-nav a {
  text-transform: none !important;
  font-size: 14px !important;
}
.sidebar .sidebar-nav a:hover {
  color: #0b87da;
  text-decoration: none !important;
  outline: 4px solid #e4e4e4;
  border-radius: 1px;
  outline-offset: -1px;
  background: #e4e4e4;
}
.sidebar .sidebar-nav strong {
  font-size: 16px !important;
}
.sidebar .sidebar-nav strong:hover {
  color: #0b87da;
  cursor: pointer;
}
.markdown-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 40px;
  width: 100%;
}
@media screen and (max-width: 768px) {
  .markdown-section {
    padding: 0 15px;
    max-width: none;
  }
}
.markdown-section a:hover,
.markdown-section a {
  text-decoration: none !important;
}
.markdown-section a:visited {
  text-decoration: none !important;
}
.sidebar img {
  width: 25px;
}
.sidebar-nav .prereq {
  color: #bd9d0f;
  font-weight: bold;
}
.sidebar-nav .lock {
  margin-left: 3px;
  /* 改用 SVG 作为背景图 */
  background: url('//doc.hardwarelab.ai/course/assets/img/lock2.svg') no-repeat center / contain;
  /* 建议设置宽高，让图标有合适大小 */
  width: 18px;          /* 根据实际图标视觉大小调整 */
  height: 14px;
  display: inline-block;   /* 重要：让宽高生效 */
  text-indent: -9999px;    /* 隐藏文字（如果 .lock 里有文字） */
  overflow: hidden;
}
.app-name-link {
  font-weight: bold;
}
.app-name::after {
  content: "官方教学文档 · IDE / ESP32 / 树莓派";
  display: block;
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}
.jconfirm .jconfirm-box {
  max-width: 480px !important;
  width: auto !important;
}
@media (min-width: 768px) {
  .jconfirm .jconfirm-box {
    max-width: 420px !important;
  }
}

/* 给所有可放大的图片加阴影(最常用) */
.medium-zoom-image {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 4px;     /* 可选:轻微圆角,看起来更现代 */
  transition: box-shadow 0.3s ease, transform 0.3s ease;  /* 平滑过渡 */
}

/* 鼠标悬停时加强阴影(提升交互感) */
/*    .medium-zoom-image:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transform: translateY(-2px);
}
*/
/* ========== 侧边栏底部用户信息区域样式 ========== */
#sidebar-user-info {
  position: fixed;
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 50px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 0 12px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 100;
  /*transition: all 0.3s ease;*/
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 当侧边栏关闭时隐藏用户信息区域(仅桌面端) */
@media screen and (min-width: 769px) {
  body.close #sidebar-user-info {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
  }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  #sidebar-user-info {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    border-top: 1px solid #4a5568;
  }
}

/* 未登录状态 */
.user-info-guest {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  width: 100%;
}

.user-info-guest .welcome-text {
  font-size: 13px;
  font-weight: normal;
  margin: 0;
}

.user-info-guest .promo-text {
  display: none;
}

.user-info-guest .promo-highlight {
  color: #ffd700;
  font-weight: bold;
  font-size: 12px;
  margin-left: 8px;
}

.user-info-guest .btn-login {
  display: inline-block;
  background: white;
  color: #667eea;
  padding: 5px 14px;
  border-radius: 15px;
  font-weight: bold;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

.user-info-guest .btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  background: #f0f0f0;
}

/* 已登录状态 */
.user-info-logged {
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.user-info-header {
  display: flex;
  align-items: center;
  margin-bottom: 0;
  flex: 1;
  color: white;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: #667eea;
  margin-right: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-vip-status {
  font-size: 10px;
  opacity: 0.9;
  white-space: nowrap;
}

.vip-badge {
  display: inline-block;
  background: #ffd700;
  color: #333;
  padding: 1px 5px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: bold;
  margin-left: 4px;
}

.user-info-promo {
  display: none;
}

.btn-upgrade {
  display: inline-block;
  background: #ffd700;
  color: #333;
  padding: 5px 12px;
  border-radius: 12px;
  font-weight: bold;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-upgrade:hover {
  transform: scale(1.05);
  background: #ffed4e;
}

.btn-logout {
  display: none;
}

/* 移动端适配 */
@media screen and (max-width: 768px) {
  #sidebar-user-info {
    width: 100%;
    left: 0;
    right: 0;
    /* 移动端始终显示,不受侧边栏影响 */
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 9999;
  }
}

/* 侧边栏内容区域底部留白,避免被用户信息区域遮挡 */
.sidebar-nav {
  padding-bottom: 60px !important;
}

/* 渐变 + 发光 */
.scroll-to-top {
  width: 50px !important;
  height: 50px !important;
  background: linear-gradient(135deg, #667eea, #764ba2) !important;
  color: white !important;
  border: none !important;
  border-radius: 50% !important;
  box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4) !important;
  font-size: 26px !important;
  line-height: 50px !important;
  transition: all 0.4s ease !important;
  cursor: pointer !important;
  
  /* 默认位置：桌面/大屏用20-30px，够用 */
  bottom: 25px !important;
  right: 25px !important;
  z-index: 9999 !important;  /* 确保在大多数元素之上 */
}

/* hover效果 */
.scroll-to-top:hover {
  transform: scale(1.1) translateY(-3px) !important;
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.6) !important;
}

/* 小屏幕适配（手机竖屏常见宽度 < 768px） */
@media only screen and (max-width: 767px) {
  .scroll-to-top {
    /* 抬高按钮：基础25px + 底部安全区（iPhone Home Bar ≈34px）+ 额外间隙避免遮挡你的50px div */
    bottom: calc(25px + env(safe-area-inset-bottom, 20px) + 60px) !important;
    /* 如果你的底部div正好50px高，这里加60px留点空隙；可调成50px或70px看实际效果 */
    
    /* 或者更简单粗暴：直接抬高到100px以上测试 */
    /* bottom: 100px !important; */
  }
}

/* 更精确：只针对有Home Bar的iOS设备（可选增强） */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media only screen and (max-width: 767px) {
    .scroll-to-top {
      bottom: calc(30px + env(safe-area-inset-bottom) + 55px) !important;
      /* env会自动取34px左右，+55px ≈ 总bottom 89px，你的50px div基本不会盖住了 */
    }
  }
}

/* 通知栏本身（做了美化处理） */
.announcement-bar {
  position: sticky;
  top: 0;
  z-index: 999;           /* 比默认 sidebar 的 z-index 高一点 */
  background: linear-gradient(135deg, #f39c12, #e74c3c); /* 渐变背景色 */
  color: white;
  text-align: center;
  padding: 6px 20px;
  font-size: 16px;
  font-weight: bold;
}

.announcement-bar .announcement-text {
  color: white;
  pointer-events: none;   /* 禁止鼠标点击 */
  cursor: default;        /* 去掉手型 */
  text-decoration: none;  /* 可选：去掉下划线 */
}

/* 活动栏中的关闭按钮 */
.announcement-bar .close-btn {
  position: absolute;
  top: 5px;
  right: 10px;
  cursor: pointer;
  font-weight: bold;
  color: white;
  transition: color 0.3s ease;
}

.announcement-bar .close-btn:hover {
  color: #f39c12; /* 鼠标悬停时按钮颜色变化 */
}

/* 核心修复 1：把 sidebar 整体往下推 */
.sidebar {
  top: 36px !important;          /* 通知栏的高度 */
  height: calc(100% - 36px) !important; /* 防止 sidebar 变短或底部露白 */
  padding-top: 0 !important;     /* 通常不需要额外内边距 */
  transition: top 0.3s ease, height 0.3s ease;  /* 添加过渡效果 */
}

/* 核心修复 2：把 sidebar 的 toggle 按钮（菜单开关）也往下移 */
.sidebar-toggle {
  top: 42px !important;          /* 和上面高度保持一致 */
  z-index: 1000;                 /* 确保它在通知栏上面（可选） */
  transition: top 0.3s ease;     /* 添加过渡效果 */
}

/* 新增：关闭通知栏后，恢复 sidebar 的布局 */
.no-announcement .sidebar {
  top: 0px !important;
  height: calc(100% - 0px) !important;
}

.no-announcement .sidebar-toggle {
  top: 10px !important;
}

.markdown-section h1 {
  text-align: center;
}

.markdown-section img {
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: box-shadow 0.3s ease, transform 0.3s ease;  /* 平滑过渡 */
}

.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4 {
    border-bottom: none;
}

/* 当通知栏显示时（body 没有 no-announcement 类） */
body:not(.no-announcement) #theme-toggle {
  --theme-toggle-top: 48px;   /* 通知栏高度36px + 额外间隙12px = 48px，你可以调成 40px / 50px 测试 */
}

/* 或者更明确：通知栏关闭后恢复 */
body.no-announcement #theme-toggle {
  --theme-toggle-top: 12px;
}

/* 主题切换按钮样式（放右上角示例） */
/* 主题切换按钮样式 */
#theme-toggle {
  position: fixed;
  top: var(--theme-toggle-top, 12px);   /* 默认 12px */
  right: 16px;
  z-index: 9999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(200,200,200,0.18);
  border: 1px solid rgba(180,180,180,0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: all 0.25s ease;
  user-select: none;
}

#theme-toggle:hover {
  background: rgba(180,180,180,0.3);
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

body.dark #theme-toggle:hover {
  background: rgba(90,90,90,0.45);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* SVG 图标颜色适配（可选，如果你的 SVG 是单色 stroke/fill） */
#theme-icon {
  transition: filter 0.3s ease;
}

.markdown-section a.anchor{
  pointer-events: none !important;
  cursor: default !important;
  text-decoration: none !important;
}

a[title="微信"],a[title="QQ"] {
  padding-left: 0!important;
}

.vip-preview-wrapper {
    position: relative;
    max-height: 500px;
    overflow: hidden;
}

.vip-mask {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(to bottom, 
        rgba(255,255,255,0) 0%, 
        rgba(255,255,255,0.8) 40%, 
        rgba(255,255,255,1) 100%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 30px;
}

body.dark .vip-mask {
    background: linear-gradient(to bottom, 
        rgba(0,0,0,0) 0%, 
        rgba(0,0,0,0.8) 40%, 
        rgba(0,0,0,1) 100%);
}

.vip-btn {
    background: #0b87da;
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    cursor: pointer;
}

.vip-mask-content{
  text-align: center;
}

.vip-lock {
  height: 15px;
  border-radius: 0!important;
  box-shadow: none!important;
  transition: none!important;
}