/* ===================================================
   悟的源码库 · Web 端全局样式
   设计语言与小程序保持一致
=================================================== */

/* ===== CSS 变量（设计令牌）===== */
:root {
  --brand:        #D4380D;
  --brand-light:  #FFF1E6;
  --brand-border: #FFBB96;
  --dark-bg:      #1E2D50;
  --dark-border:  #2D3F66;
  --accent:       #FF6B35;
  --blue:         #1677FF;
  --blue-light:   #E6F4FF;
  --green:        #52C41A;
  --text-1:       #1A1A2E;
  --text-2:       #555;
  --text-3:       #888;
  --text-4:       #BBB;
  --text-5:       #DDD;
  --bg:           #F5F6FA;
  --card:         #FFFFFF;
  --border:       #EBEBEB;
  --shadow-sm:    0 1px 4px rgba(0,0,0,0.06);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.12);
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --navbar-h:     64px;
  --sidebar-w:    200px;
  --max-w:        1200px;
  --transition:   0.18s ease;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
img { max-width: 100%; display: block; }
pre, code { font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace; }

/* ===== 布局容器 ===== */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 20px; }

/* ===================================================
   导航栏
=================================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--navbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.navbar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}
.navbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-decoration: none;
}
.navbar-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--brand);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.navbar-logo-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
  white-space: nowrap;
}
.navbar-logo-text span { color: var(--brand); }

/* 搜索框 */
.navbar-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.navbar-search-input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 16px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-1);
  background: var(--bg);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.navbar-search-input::placeholder { color: var(--text-4); }
.navbar-search-input:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(212,56,13,0.08);
}
.navbar-search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  font-size: 16px;
  pointer-events: none;
}
.navbar-search-clear {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
}
.navbar-search-clear:hover { color: var(--text-2); }

.navbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}
.navbar-link {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.navbar-link:hover, .navbar-link.active { background: var(--brand-light); color: var(--brand); }

/* 移动端搜索按钮 */
.navbar-search-btn {
  width: 40px; height: 40px;
  border-radius: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 18px;
  background: var(--bg);
  transition: background var(--transition);
}
.navbar-search-btn:hover { background: var(--border); }

/* 移动端搜索展开栏 */
.mobile-search-bar {
  display: none;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.mobile-search-bar.open { display: block; }
.mobile-search-bar .navbar-search { max-width: 100%; }

/* ===================================================
   主体布局
=================================================== */
.layout {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 20px;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 24px;
  align-items: start;
}

/* ===================================================
   分类侧栏 (PC)
=================================================== */
.sidebar {
  position: sticky;
  top: calc(var(--navbar-h) + 16px);
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.sidebar-title {
  padding: 14px 16px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.cat-list { padding: 8px 0; }
.cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
  user-select: none;
}
.cat-item:hover { background: var(--bg); color: var(--text-1); }
.cat-item.active {
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 600;
}
.cat-item-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background var(--transition);
}
.cat-item.active .cat-item-dot { background: var(--brand); }

/* ===================================================
   移动端分类标签（水平滚动）
=================================================== */
.cat-tabs {
  display: none;
  overflow-x: auto;
  padding: 12px 16px;
  gap: 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--navbar-h);
  z-index: 90;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-2);
  background: var(--bg);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  user-select: none;
}
.cat-tab:hover { background: var(--border); }
.cat-tab.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }

/* ===================================================
   主内容区
=================================================== */
.main { min-width: 0; }

/* ===================================================
   热门指标
=================================================== */
.hot-section { margin-bottom: 20px; }
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}
.section-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(255,107,53,0.1);
}

.hot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.hot-card {
  background: var(--dark-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--dark-border);
  padding: 16px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  display: block;
  position: relative;
  overflow: hidden;
  min-height: 120px;
}
.hot-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: radial-gradient(circle at top right, rgba(255,107,53,0.15), transparent 70%);
  pointer-events: none;
}
.hot-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(30,45,80,0.4); }
.hot-card-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.hot-card-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin-bottom: 12px;
}
.hot-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hot-card-rate {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}
.hot-card-img {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  opacity: 0.85;
}

/* 热门骨架屏 */
.hot-skeleton {
  background: var(--dark-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--dark-border);
  min-height: 120px;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

/* ===================================================
   统计栏
=================================================== */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0 16px;
  font-size: 13px;
  color: var(--text-3);
}
.stats-num { color: var(--brand); font-weight: 700; }
.stats-new { color: var(--green); font-weight: 700; }
.stats-divider { color: var(--border); }

/* ===================================================
   卡片列表
=================================================== */
.card-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-count { font-size: 13px; color: var(--text-3); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.code-card {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 16px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  box-shadow: var(--shadow-sm);
}
.code-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #D9D9D9;
  transform: translateY(-1px);
}
.code-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.code-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  flex: 1;
  min-height: 2.9em;
}
.cat-badge {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-light);
}
.mobile-badge {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-light);
}
.code-card-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-bottom-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.code-card-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-4);
}
.stat-item { display: flex; align-items: center; gap: 4px; }
.stat-icon { font-size: 12px; }
.code-card-date {
  font-size: 12px;
  color: var(--text-5);
}
.code-card-date.today { color: var(--brand); font-weight: 600; }
.code-card-date.yesterday { color: var(--green); font-weight: 500; }

/* ===================================================
   骨架屏
=================================================== */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.skeleton {
  background: var(--border);
  border-radius: 4px;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
.card-skeleton {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sk-line { height: 14px; border-radius: 4px; }
.sk-short { width: 40%; }
.sk-long { width: 85%; }
.sk-full { width: 100%; }
.sk-medium { width: 60%; }

/* ===================================================
   加载更多 / 空状态
=================================================== */
.load-more-wrap { display: flex; justify-content: center; padding: 24px 0; }
.btn-load-more {
  padding: 10px 32px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  font-size: 14px;
  color: var(--text-2);
  background: var(--card);
  transition: border-color var(--transition), color var(--transition), box-shadow var(--transition);
}
.btn-load-more:hover { border-color: var(--brand); color: var(--brand); box-shadow: var(--shadow-sm); }
.btn-load-more:disabled { opacity: 0.5; cursor: not-allowed; }

.no-more-tip { text-align: center; padding: 20px 0; font-size: 13px; color: var(--text-5); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  gap: 12px;
}
.empty-icon { font-size: 40px; }
.empty-text { font-size: 15px; color: var(--text-3); }
.empty-sub { font-size: 13px; color: var(--text-4); }

/* ===================================================
   详情页
=================================================== */
.detail-layout {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}
.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 20px;
  cursor: pointer;
  transition: color var(--transition);
}
.detail-back:hover { color: var(--text-1); }
.detail-back-arrow { font-size: 18px; line-height: 1; }

.detail-header {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.detail-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-1);
  line-height: 1.4;
  margin-bottom: 16px;
}
.detail-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-3);
}
.detail-stat-item { display: flex; align-items: center; gap: 4px; }

/* 效果图 */
.detail-image-wrap {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.detail-image {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  display: block;
  background: #F8F8F8;
}
.detail-image-label {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-4);
  border-top: 1px solid var(--border);
  text-align: center;
}

/* 源码区域 */
.code-wrap {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.code-toolbar-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.btn-copy {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
}
.btn-copy:hover { background: #b52e0a; transform: translateY(-1px); }
.btn-copy.copied { background: var(--green); }
.code-block {
  padding: 20px;
  overflow-x: auto;
  max-height: 520px;
  overflow-y: auto;
}
.code-block pre {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-1);
  white-space: pre-wrap;
  word-break: break-all;
  tab-size: 4;
}

/* 相关推荐 */
.related-section { margin-top: 24px; }
.related-title { font-size: 16px; font-weight: 700; color: var(--text-1); margin-bottom: 12px; }
.related-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.related-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition: box-shadow var(--transition), border-color var(--transition);
  box-shadow: var(--shadow-sm);
}
.related-card:hover { box-shadow: var(--shadow-md); border-color: #D9D9D9; }
.related-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin-bottom: 8px;
  line-height: 1.4;
}
.related-card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-4); }

/* ===================================================
   页脚
=================================================== */
.footer {
  border-top: 1px solid var(--border);
  background: var(--card);
  padding: 40px 20px 28px;
  margin-top: 40px;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 48px;
}
.footer-left {
  display: flex;
  gap: 24px;
  flex-shrink: 0;
}
.footer-qr-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.footer-qr {
  width: 120px;
  height: 120px;
  min-width: 120px;
  border-radius: 10px;
  object-fit: contain;
  border: 1px solid var(--border);
  padding: 6px;
  background: #fff;
  display: block;
}
.footer-qr-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.footer-divider {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  flex-shrink: 0;
}
.footer-right {
  flex: 1;
  min-width: 0;
}
.footer-about-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 10px;
}
.footer-about-desc {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.8;
  margin-bottom: 18px;
}
.footer-disclaimer-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 6px;
}
.footer-disclaimer {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.8;
  margin-bottom: 20px;
}
.footer-icp {
  font-size: 12px;
  color: var(--text-4);
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.footer-icp a { color: var(--text-4); }
.footer-icp a:hover { color: var(--brand); }

/* ===================================================
   Toast 提示
=================================================== */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(26,26,46,0.88);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===================================================
   响应式 · 平板（<1024px）
=================================================== */
@media (max-width: 1023px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 0 0 24px;
  }
  .sidebar { display: none; }
  .cat-tabs { display: flex; }
  .hot-grid { grid-template-columns: repeat(3, 1fr); }
  .main { padding: 0 16px; }
  .stats-bar { padding-top: 16px; }
}

/* ===================================================
   响应式 · 手机（<640px）
=================================================== */
@media (max-width: 639px) {
  :root { --navbar-h: 54px; }
  .navbar-inner { padding: 0 16px; gap: 12px; }
  .navbar-search { display: none; }
  .navbar-search-btn { display: flex; }
  .navbar-logo-text { font-size: 16px; }
  .navbar-links { display: none; }
  .hot-section { padding-top: 16px; margin-bottom: 16px; }
  .hot-grid {
    grid-template-columns: 1fr;
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 8px;
    scrollbar-width: none;
  }
  .hot-grid::-webkit-scrollbar { display: none; }
  .hot-card { min-width: 78vw; flex-shrink: 0; }
  .hot-skeleton { min-width: 78vw; flex-shrink: 0; min-height: 110px; }
  .card-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
  .detail-layout { padding: 16px 16px 60px; }
  .detail-title { font-size: 19px; }
  .main { padding: 0 12px; }
  /* 统计栏：手机端允许换行，字号缩小 */
  .stats-bar {
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: 12px;
    padding: 10px 0 12px;
  }
  .stats-divider { display: none; }
  /* 页脚：手机端上下布局 */
  .footer { padding: 28px 16px 20px; }
  .footer-inner { flex-direction: column; gap: 24px; }
  .footer-left { justify-content: center; gap: 32px; }
  .footer-divider { width: 100%; height: 1px; align-self: auto; }
  .footer-qr { width: 100px; height: 100px; min-width: 100px; }
  .footer-right { text-align: center; }
  .footer-icp { text-align: center; }
}

/* ===================================================
   PC 三列（≥1200px）
=================================================== */
@media (min-width: 1200px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}
