/* ============================================================
   网站模板 · 主样式
   主题色: #16baaa（青绿）
   覆盖: 顶部导航 / 首页各区块 / 文章页 / 页脚 / 表单
   ============================================================ */

:root {
  --primary: #16baaa;
  --primary-dark: #0e9b8e;
  --primary-light: rgba(22, 186, 170, .1);
  --text: #2b3333;
  --muted: #7a8787;
  --bg: #ffffff;
  --bg-soft: #f5f9f9;
  --border: #e4eeee;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .06);
  --shadow-lg: 0 6px 24px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--primary); text-decoration: none; transition: color .2s; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ============ 顶部导航 ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 24px;
}
.logo { flex-shrink: 0; }
.logo-h1 { font-size: 0; }
.logo-img { height: 34px; width: auto; }

.main-nav { flex: 1; }
.nav-list { display: flex; align-items: center; gap: 4px; }
.nav-list > li { position: relative; }
.nav-list > li > a {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
}
.nav-list > li > a:hover { color: var(--primary); background: var(--primary-light); }
.nav-list > li.current > a { color: var(--primary); background: var(--primary-light); }

.sub-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: all .2s;
}
.nav-list > li.has-sub:hover .sub-menu,
.nav-list > li.has-sub:focus-within .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.sub-menu li a {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}
.sub-menu li a:hover { color: var(--primary); background: var(--primary-light); }

.user-area { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-link { color: var(--muted); font-size: 14px; padding: 8px 12px; }
.user-link:hover { color: var(--primary); }

/* ============ 通用区块标题 ============ */
.section-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  position: relative;
  padding-left: 14px;
}
.section-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: 2px;
  background: var(--primary);
}
.section-subtitle { color: var(--muted); margin-bottom: 24px; }
section { padding: 48px 0; }

/* ============ 轮播 ============ */
.carousel {
  background: linear-gradient(135deg, #eafcfa 0%, #f5f9f9 100%);
  padding: 56px 0;
}
.carousel-slide { display: none; }
.carousel-slide.active { display: block; animation: fadeIn .4s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.carousel-overlay { max-width: 720px; }
.carousel-overlay h2 { font-size: 34px; line-height: 1.3; margin-bottom: 12px; }
.carousel-overlay h2 a { color: var(--text); }
.carousel-overlay h2 a:hover { color: var(--primary); }
.carousel-overlay p { color: var(--muted); font-size: 16px; }
.carousel-nav { margin-top: 20px; display: flex; gap: 8px; }
.carousel-nav button {
  border: 1px solid var(--border);
  background: #fff;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--muted);
}
.carousel-nav button:hover { color: var(--primary); border-color: var(--primary); }

/* ============ 置顶文章卡片 ============ */
.top-articles { background: var(--bg-soft); }
.top-articles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.top-article-card {
  display: block;
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.top-article-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.top-article-card .card-title { font-size: 17px; font-weight: 600; color: var(--text); line-height: 1.5; margin-bottom: 8px; }
.top-article-card:hover .card-title { color: var(--primary); }
.top-article-card .card-desc { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.top-article-card .card-meta { margin-top: 14px; color: var(--muted); font-size: 13px; display: flex; gap: 12px; }
.top-article-card .card-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  margin-right: 6px;
}

/* ============ 新闻列表区 ============ */
.news-section { background: #fff; }
.news-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.news-col {
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid var(--border);
}
.news-col-title { font-size: 16px; font-weight: 700; color: var(--text); display: block; margin-bottom: 14px; position: relative; padding-left: 12px; }
.news-col-title::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; border-radius: 2px; background: var(--primary); }
.news-list { display: flex; flex-direction: column; gap: 2px; }
.news-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 8px;
  transition: background .2s;
}
.news-item:hover { background: #fff; }
.news-title {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.news-item:hover .news-title { color: var(--primary); }
.news-date { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.news-col-footer { margin-top: 12px; text-align: right; }
.view-all-link { font-size: 13px; color: var(--primary); }
.view-all-link:hover { text-decoration: underline; }

/* ============ 开源区 ============ */
.opensource-section { background: var(--bg-soft); }
.os-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.os-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.os-card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.os-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.os-name { font-size: 17px; font-weight: 600; }
.os-desc { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.os-meta { display: flex; gap: 16px; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.os-actions { display: flex; gap: 10px; }
.os-btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background .2s;
}
.os-btn:hover { background: var(--primary-dark); color: #fff; }
.os-btn.is-plain { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.os-btn.is-plain:hover { background: var(--primary-light); }
.os-btn-github { background: #24292f; }
.os-btn-github:hover { background: #000; color: #fff; }
.os-btn-doc { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.os-btn-doc:hover { background: var(--primary-light); color: var(--primary-dark); }

/* ============ 工坊区 ============ */
.home-workshop { background: #fff; }
.home-workshop-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.home-workshop-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.home-workshop-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.home-workshop-cover { height: 130px; background: linear-gradient(135deg, var(--primary-light), #eafcfa); display: flex; align-items: center; justify-content: center; }
.home-workshop-cover img { max-height: 90px; }
.home-workshop-body { padding: 16px 18px 18px; }
.home-workshop-type { font-size: 12px; color: var(--primary); background: var(--primary-light); padding: 2px 10px; border-radius: 999px; display: inline-block; margin-bottom: 8px; }
.home-workshop-body h3 { font-size: 16px; margin-bottom: 6px; }
.home-workshop-body h3 a { color: var(--text); }
.home-workshop-body h3 a:hover { color: var(--primary); }
.home-workshop-meta { color: var(--muted); font-size: 13px; }
.home-workshop-price { margin-top: 10px; color: var(--primary); font-weight: 700; font-size: 16px; }

/* ============ 活动区 ============ */
.home-activities { background: var(--bg-soft); }
.act-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.act-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform .2s, box-shadow .2s;
}
.act-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.act-chip { display: inline-block; font-size: 12px; color: var(--primary); background: var(--primary-light); padding: 2px 10px; border-radius: 999px; margin-bottom: 10px; }
.act-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.act-title a { color: var(--text); }
.act-title a:hover { color: var(--primary); }
.act-desc { color: var(--muted); font-size: 13px; margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.act-meta { color: var(--muted); font-size: 12px; }
.act-live-card { border-color: rgba(22, 186, 170, .4); }
.act-live-bar { display: inline-block; font-size: 11px; color: #fff; background: var(--primary); padding: 2px 8px; border-radius: 4px; margin-right: 6px; }
.act-live-off { background: #9aa6a6; }
.act-sub-btn { margin-top: 12px; }
.act-sub-label { font-size: 12px; color: var(--muted); }

/* ============ 子分类/历史标签 ============ */
.sub-cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.sub-cat-card {
  display: block;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: transform .2s, box-shadow .2s;
}
.sub-cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.cat-icon { font-size: 26px; margin-bottom: 6px; }
.cat-name { font-size: 14px; color: var(--text); }
.history-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.history-tag {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}
.history-tag:hover { color: var(--primary); border-color: var(--primary); }

/* ============ 文章页 ============ */
.article-container { padding: 32px 0 56px; }
.article-wrapper { display: flex; gap: 28px; align-items: flex-start; }
.article-main { flex: 1; min-width: 0; }
.article-header { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.article-header h1 { font-size: 28px; line-height: 1.4; margin-bottom: 12px; }
.article-meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 14px; }
.article-meta .date { color: var(--muted); }

.article-body { font-size: 16px; }
.article-body h2 { font-size: 22px; margin: 28px 0 12px; padding-left: 12px; border-left: 4px solid var(--primary); }
.article-body h3 { font-size: 18px; margin: 22px 0 10px; }
.article-body p { margin-bottom: 14px; }
.article-body ul, .article-body ol { list-style: disc; padding-left: 22px; margin-bottom: 14px; }
.article-body ol { list-style: decimal; }
.article-body li { margin-bottom: 6px; }
.article-body a { text-decoration: underline; text-underline-offset: 3px; }
.article-body strong { font-weight: 700; }
.article-body img { border-radius: 8px; margin: 12px 0; box-shadow: var(--shadow); }
.article-body blockquote {
  border-left: 4px solid var(--primary);
  background: var(--bg-soft);
  padding: 12px 18px;
  margin: 16px 0;
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}
.article-body code {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 14px;
  font-family: "SF Mono", Consolas, "Courier New", monospace;
}
.article-body pre {
  background: #1e2a2a;
  color: #e6f2f2;
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}
.article-body pre code { background: none; border: none; color: inherit; padding: 0; }
.article-body table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.article-body th { background: var(--bg-soft); font-weight: 600; }

.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 32px;
  padding: 18px;
  background: var(--bg-soft);
  border-radius: var(--radius);
}
.article-nav a { font-size: 14px; color: var(--text); max-width: 48%; }
.article-nav a:hover { color: var(--primary); }

/* 侧边栏 */
.article-sidebar { width: 300px; flex-shrink: 0; position: sticky; top: 84px; }
.sidebar-inner {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.sidebar-header {
  font-size: 15px;
  font-weight: 700;
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  position: relative;
  padding-left: 12px;
}
.sidebar-header::before { content: ""; position: absolute; left: 0; top: 2px; bottom: 12px; width: 3px; border-radius: 2px; background: var(--primary); }
.sidebar-list { display: flex; flex-direction: column; gap: 2px; }
.sidebar-list li a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}
.sidebar-list li a:hover { color: var(--primary); background: var(--primary-light); }
.sidebar-list li.current a { color: var(--primary); background: var(--primary-light); font-weight: 600; }
.sidebar-omitted { color: var(--muted); font-size: 13px; padding: 8px 10px; }

/* 分享面板 */
.article-share-trigger {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(22, 186, 170, .3);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.article-share-trigger:hover { background: var(--primary); color: #fff; }
.article-share-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.article-share-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }
.article-share-main {
  position: relative;
  background: #fff;
  border-radius: 14px;
  width: 420px;
  max-width: 92vw;
  padding: 22px;
  box-shadow: var(--shadow-lg);
}
.article-share-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.article-share-title { font-weight: 700; }
.article-share-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.article-share-preview { background: var(--bg-soft); border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.article-share-logo img { height: 30px; margin-bottom: 8px; }
.article-share-preview-title { font-weight: 600; margin-bottom: 4px; }
.article-share-preview-desc { color: var(--muted); font-size: 13px; }
.article-share-field { margin-bottom: 14px; }
.article-share-field-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.article-share-link { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.article-share-actions { display: flex; gap: 10px; }
.article-share-primary { flex: 1; background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 9px; cursor: pointer; font-weight: 500; }
.article-share-primary:hover { background: var(--primary-dark); }
.article-share-secondary { flex: 1; background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 9px; cursor: pointer; }
.article-share-toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 300;
}

/* 作者栏 */
.article-author-bar {
  margin-top: 24px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 14px;
  color: var(--muted);
}

/* ============ 表单 / 认证 ============ */
.auth-panel {
  max-width: 420px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; margin-bottom: 6px; color: var(--text); }
.form-group input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color .2s;
}
.form-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.auth-submit {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.auth-submit:hover { background: var(--primary-dark); }
.auth-foot { margin-top: 16px; text-align: center; font-size: 14px; color: var(--muted); }
.auth-foot a { color: var(--primary); }
.auth-form-msg { font-size: 13px; margin-bottom: 12px; }
.auth-form-msg.is-err { color: #e5484d; }
.auth-form-msg.is-ok { color: var(--primary); }
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-img { height: 42px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; }
.code-row { display: flex; gap: 10px; }
.code-btn {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(22, 186, 170, .3);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}
.code-btn:hover { background: var(--primary); color: #fff; }

/* ============ 页脚 ============ */
.site-footer {
  background: #1e2a2a;
  color: #b7c6c6;
  padding: 40px 0 24px;
  margin-top: 24px;
}
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; }
.footer-brand .logo-img { height: 30px; margin-bottom: 12px; filter: brightness(0) invert(1); }
.footer-brand p { font-size: 14px; line-height: 1.8; }
.footer-col h4 { color: #fff; font-size: 15px; margin-bottom: 12px; }
.footer-links { display: flex; flex-direction: column; gap: 8px; }
.footer-links a { color: #b7c6c6; font-size: 14px; }
.footer-links a:hover { color: var(--primary); }
.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, .1);
  margin-top: 28px;
  padding-top: 18px;
  text-align: center;
  font-size: 13px;
  color: #8a9a9a;
}

/* ============ 通知条 / 杂项 ============ */
.notice-item { display: block; padding: 10px 14px; border-radius: 8px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--text); font-size: 14px; margin-bottom: 8px; }
.notice-item:hover { border-color: var(--primary); color: var(--primary); }
.btn-ico { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 16px; }

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .top-articles-grid, .news-cols, .home-workshop-grid, .act-grid { grid-template-columns: repeat(2, 1fr); }
  .os-grid, .sub-cat-grid { grid-template-columns: repeat(2, 1fr); }
  .article-wrapper { flex-direction: column; }
  .article-sidebar { width: 100%; position: static; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .top-articles-grid, .news-cols, .home-workshop-grid, .act-grid, .os-grid, .sub-cat-grid { grid-template-columns: 1fr; }
  .header-inner { flex-wrap: wrap; height: auto; padding: 10px 0; }
  .nav-list { flex-wrap: wrap; }
  .carousel-overlay h2 { font-size: 24px; }
  .footer-inner { grid-template-columns: 1fr; }
  section { padding: 32px 0; }
}

/* 缺图兜底：原站图片未下载时显示浅色占位块 */
img[src*="/static/uploads/"] { background: var(--bg-soft) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Crect width='48' height='48' fill='%23e4eeee'/%3E%3Ctext x='24' y='29' font-size='12' fill='%237a8787' text-anchor='middle' font-family='sans-serif'%3Eimg%3C/text%3E%3C/svg%3E") center/48px no-repeat; min-height: 120px; }
