/* ============================================================
   开源发现 · OpenSource Radar 设计系统
   风格：GitHub 原生设计语言。深色默认，浅色可选。
   变量分 dark/light 两套，通过 html[data-theme] 切换。
   ============================================================ */

:root, html[data-theme="dark"] {
  --bg: #0d1117;            /* 页面背景 */
  --bg-inset: #010409;      /* 更深一层 */
  --card: #161b22;          /* 卡片背景 */
  --card-hover: #1c2129;
  --border: #30363d;        /* 低对比边框 */
  --border-muted: #21262d;
  --text: #e6edf3;          /* 主文字 */
  --text-muted: #7d8590;    /* 次级文字 */
  --text-faint: #6e7681;
  --primary: #238636;       /* GitHub 绿（按钮） */
  --primary-hover: #2ea043;
  --green: #3fb950;         /* 成功/增长 */
  --accent: #58a6ff;        /* 链接蓝 */
  --warning: #d29922;
  --danger: #f85149;
  --done: #a371f7;
  --btn-bg: #21262d;
  --btn-hover: #30363d;
  --shadow: 0 0 transparent;
  --code-bg: #161b22;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #ffffff;
  --bg-inset: #f6f8fa;
  --card: #ffffff;
  --card-hover: #f6f8fa;
  --border: #d0d7de;
  --border-muted: #d8dee4;
  --text: #1f2328;
  --text-muted: #656d76;
  --text-faint: #8c959f;
  --primary: #1f883d;
  --primary-hover: #1a7f37;
  --green: #1a7f37;
  --accent: #0969da;
  --warning: #9a6700;
  --danger: #cf222e;
  --done: #8250df;
  --btn-bg: #f6f8fa;
  --btn-hover: #eef1f4;
  --shadow: 0 1px 0 rgba(31,35,40,.04);
  --code-bg: #f6f8fa;
  color-scheme: light;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
    "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.55;
  background: var(--bg); color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 16px; }
code, pre, .mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 12.5px;
}
pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 12px; overflow-x: auto;
}
img { max-width: 100%; }
::selection { background: rgba(56,139,253,.4); }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--bg-inset);
  border-right: 1px solid var(--border-muted);
  padding: 16px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-muted);
  background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.content { padding: 20px; max-width: 1200px; width: 100%; margin: 0 auto; }
.footer {
  margin-top: auto; padding: 20px; color: var(--text-faint);
  border-top: 1px solid var(--border-muted); font-size: 12px;
}

/* ---------- 侧边导航 ---------- */
.logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 15px; color: var(--text);
  padding: 4px 8px 16px;
}
.logo .octicon { color: var(--green); }
.nav-group { margin-bottom: 4px; }
.nav-title {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
  padding: 12px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px;
  color: var(--text); font-size: 14px;
}
.nav-item:hover { background: var(--btn-hover); text-decoration: none; }
.nav-item.active { background: var(--btn-bg); font-weight: 600; }
.nav-item .octicon { color: var(--text-muted); flex-shrink: 0; }
.nav-item.active .octicon { color: var(--green); }
.nav-badge {
  margin-left: auto; font-size: 11px; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 10px; padding: 0 6px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--btn-bg); color: var(--text);
  font-size: 14px; font-weight: 500; line-height: 20px;
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background .12s;
}
.btn:hover { background: var(--btn-hover); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: rgba(240,246,252,.1); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(248,81,73,.15); border-color: var(--danger); }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- 表单 ---------- */
.input, .select, textarea.input {
  width: 100%; padding: 5px 12px;
  background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; line-height: 20px; font-family: inherit;
}
.input:focus, .select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,139,253,.25);
}
.form-row { margin-bottom: 14px; }
.form-label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; padding: 16px;
}
.card + .card { margin-top: 12px; }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }

/* ---------- 项目卡片 ---------- */
.repo-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; padding: 16px;
  transition: border-color .12s, background .12s;
  display: flex; flex-direction: column; gap: 8px;
  cursor: pointer;                       /* 整卡可点击 */
}
.repo-card:hover { border-color: var(--text-faint); background: var(--card-hover); }
.repo-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.repo-card h3 { margin: 0; font-size: 15px; word-break: break-all; }
.repo-card h3 a { color: var(--accent); }
.name-zh { color: var(--text-muted); font-weight: 400; }
.zh-missing { color: var(--text-faint); font-size: 12px; font-style: normal; }
.repo-desc {
  color: var(--text-muted); font-size: 13px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.repo-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--text-muted); font-size: 12px; align-items: center; }
.repo-meta .octicon { vertical-align: -2px; margin-right: 2px; }
.score-pill {
  font-weight: 600; font-size: 12px; padding: 1px 8px;
  border-radius: 12px; border: 1px solid var(--border);
}
.score-high { color: var(--green); border-color: rgba(63,185,80,.5); }
.score-mid { color: var(--warning); border-color: rgba(210,153,34,.5); }
.score-low { color: var(--text-muted); }
.grid-repos {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

/* ---------- 徽章 / 标签 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; padding: 1px 8px; border-radius: 12px;
  border: 1px solid var(--border); color: var(--text-muted);
}
.badge-green { color: var(--green); border-color: rgba(63,185,80,.4); }
.badge-blue { color: var(--accent); border-color: rgba(88,166,255,.4); }
.badge-warning { color: var(--warning); border-color: rgba(210,153,34,.4); }
.badge-danger { color: var(--danger); border-color: rgba(248,81,73,.4); }
.topic-tag {
  display: inline-block; font-size: 12px; padding: 0 8px;
  background: rgba(56,139,253,.12); color: var(--accent);
  border-radius: 12px; line-height: 20px; text-decoration: none !important;
}
.lang-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; vertical-align: -1px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 10px 12px; font-weight: 600;
  background: var(--bg-inset); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border-muted); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--card-hover); }

/* ---------- Tab 导航 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab {
  padding: 8px 14px; color: var(--text-muted); font-size: 14px;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); font-weight: 600; border-bottom-color: #f78166; }

/* ---------- 评分条 ---------- */
.scorebar { background: var(--bg-inset); border-radius: 6px; height: 8px; overflow: hidden; border: 1px solid var(--border-muted); }
.scorebar > span { display: block; height: 100%; background: var(--green); }
.dim-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; }
.dim-row .name { width: 150px; flex-shrink: 0; color: var(--text-muted); }
.dim-row .bar { flex: 1; }
.dim-row .val { width: 40px; text-align: right; font-weight: 600; }

/* ---------- 骨架屏 / 空状态 ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--btn-bg) 25%, var(--card-hover) 50%, var(--btn-bg) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
  border-radius: 6px; min-height: 14px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.empty {
  text-align: center; color: var(--text-muted); padding: 48px 20px;
  border: 1px dashed var(--border); border-radius: 6px;
}
.empty .octicon { opacity: .5; margin-bottom: 8px; }

/* ---------- 提示 / Toast ---------- */
.flash {
  padding: 10px 14px; border-radius: 6px; margin-bottom: 14px;
  border: 1px solid; font-size: 13px;
}
.flash-info { color: var(--accent); border-color: rgba(88,166,255,.4); background: rgba(88,166,255,.08); }
.flash-warn { color: var(--warning); border-color: rgba(210,153,34,.4); background: rgba(210,153,34,.08); }
.flash-danger { color: var(--danger); border-color: rgba(248,81,73,.4); background: rgba(248,81,73,.08); }
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 9px 18px; border-radius: 6px; font-size: 13px; z-index: 100;
  transition: transform .2s; box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- 推广位 ---------- */
.promo {
  border: 1px solid var(--border-muted); border-radius: 6px;
  padding: 12px; background: var(--bg-inset); position: relative;
}
.promo .promo-tag {
  position: absolute; top: -9px; right: 10px;
  font-size: 10px; color: var(--text-faint);
  background: var(--bg); padding: 0 6px; border: 1px solid var(--border-muted);
  border-radius: 8px;
}
.promo h4 { margin: 0 0 4px; font-size: 13px; }
.promo p { margin: 0 0 8px; font-size: 12px; color: var(--text-muted); }

/* 数据新鲜度徽标 */
.fresh-badge {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 8px; padding: 1px 8px;
  border: 1px solid var(--border-muted); border-radius: 10px;
  font-size: 12px; color: var(--text-muted); background: var(--bg);
}

/* 首页顶部赞助横幅 */
.promo-banner { margin: 0 0 12px; padding: 10px 12px; }
.promo-banner .promo-banner-link {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  color: var(--text); text-decoration: none; font-size: 13px;
}
.promo-banner .promo-banner-link:hover b { color: var(--accent, #3fb950); }
.promo-banner-brand {
  background: var(--accent, #3fb950); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  padding: 3px 8px; border-radius: 4px; white-space: nowrap;
}
.promo-banner-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.promo-banner-desc { color: var(--text-muted); font-size: 12px; }
.promo-banner-price { color: var(--accent, #3fb950); font-weight: 700; white-space: nowrap; }
.promo-banner-cta {
  margin-left: auto; white-space: nowrap;
  border: 1px solid var(--accent, #3fb950); color: var(--accent, #3fb950);
  font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.promo-banner-link:hover .promo-banner-cta { background: var(--accent, #3fb950); color: #fff; }
.promo-html { font-size: 13px; overflow-x: auto; }
.promo-html img { max-width: 100%; height: auto; }
.promo-html a { text-decoration: none; }
/* 联盟广告位内部通用样式（管理员自定义 html_code 可直接复用） */
.promo-html .ad-flex { display: flex; align-items: center; gap: 16px; }
.promo-html .ad-illus { flex-shrink: 0; }
@media (max-width: 640px) {
  .promo-html .ad-illus { display: none; }
  .promo-html .ad-flex { gap: 10px; }
}

/* ---------- 移动端 ---------- */
.menu-btn { display: none; }
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50;
    transform: translateX(-100%); transition: transform .2s;
    height: 100vh; box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .content { padding: 12px; }
  .grid-repos { grid-template-columns: 1fr; }
  .dim-row .name { width: 110px; font-size: 12px; }
  .topbar { padding: 10px 12px; }
  .hide-mobile { display: none !important; }
  .search-form { flex: 1; }
}
#sidebar-mask { display: none; }
@media (max-width: 900px) {
  #sidebar-mask.show {
    display: block; position: fixed; inset: 0;
    background: rgba(1,4,9,.6); z-index: 40;
  }
}

/* ---------- 详情页 ---------- */
.detail-header { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-header h1 { margin: 0; word-break: break-all; }
.detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.stat-box { display: flex; gap: 16px; flex-wrap: wrap; margin: 12px 0; }
.stat-box > div { text-align: center; }
.stat-box .n { font-size: 18px; font-weight: 700; }
.stat-box .t { font-size: 12px; color: var(--text-muted); }
.section { margin-top: 20px; }
.section > h2 {
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.fact-tag { font-size: 11px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--border); color: var(--text-muted); white-space: nowrap; }
.fact-verified { color: var(--green); border-color: rgba(63,185,80,.4); }
.fact-data { color: var(--accent); border-color: rgba(88,166,255,.4); }
.fact-guess { color: var(--warning); border-color: rgba(210,153,34,.4); }
.copy-btn { position: relative; }
.markdown-body { font-size: 14px; }
.markdown-body h1, .markdown-body h2 { border-bottom: 1px solid var(--border-muted); padding-bottom: .3em; }
.markdown-body ul, .markdown-body ol { padding-left: 22px; }
.markdown-body blockquote { margin: 0; padding: 0 12px; color: var(--text-muted); border-left: 3px solid var(--border); }
.markdown-body table { border-collapse: collapse; display: block; max-width: 100%; overflow-x: auto; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border-muted); padding: 6px 10px; }
.markdown-body th { background: var(--bg-inset, rgba(0,0,0,.15)); }
.markdown-body pre { background: var(--bg-inset, rgba(0,0,0,.25)); border: 1px solid var(--border-muted);
  border-radius: 6px; padding: 12px 14px; overflow-x: auto; font-size: 13px; }
.markdown-body code { background: var(--bg-inset, rgba(0,0,0,.2)); border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.markdown-body pre code { background: transparent; padding: 0; }
.markdown-body img { max-width: 100%; }
.markdown-body .codehilite { background: var(--bg-inset, rgba(0,0,0,.25)); border-radius: 6px; }
/* ---------- 分类折叠筛选 ---------- */
details.cat-filter {
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); padding: 10px 14px; margin-bottom: 16px;
}
details.cat-filter summary {
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14px; list-style: none; user-select: none;
}
details.cat-filter summary::-webkit-details-marker { display: none; }
details.cat-filter summary::after {
  content: "展开 ▾"; margin-left: auto; font-size: 12px;
  color: var(--text-muted); font-weight: 400;
}
details.cat-filter[open] summary::after { content: "收起 ▴"; }
details.rawbox {
  border: 1px dashed var(--border); border-radius: 6px;
  padding: 10px 14px; margin-top: 10px;
}
details.rawbox summary { cursor: pointer; color: var(--text-muted); font-size: 13px; }
.readme-md { line-height: 1.7; }
.readme-md pre, .readme-md code { white-space: pre-wrap; }

.spark { width: 100%; height: 60px; }
.dir-card { border-left: 3px solid var(--green); }

/* 科普导流条 */
.guide-strip {
  margin: -4px 0 12px; padding: 6px 12px;
  font-size: 12px; color: var(--text-muted);
  border: 1px dashed var(--border); border-radius: 6px;
  background: var(--bg-inset);
}
.guide-strip a { color: var(--accent); text-decoration: none; font-weight: 600; }
.guide-strip a:hover { text-decoration: underline; }
.guide-item { border-left: 3px solid var(--green); padding: 2px 0 2px 12px; }
.guide-item p { margin: 3px 0 0; font-size: 12px; color: var(--text-muted); }

/* 曾经爆款徽章 */
.badge-hot {
  display: inline-flex; align-items: center; gap: 3px;
  color: #f0883e; border: 1px solid rgba(240,136,62,.35);
  background: rgba(240,136,62,.08);
}
