/* ==========================================================================
   CodeHub 源码站 · 样式表
   纯 CSS，无外部字体与图片依赖，符合 CSP: style-src 'self'
   ========================================================================== */

:root {
  --bg: #070a11;
  --bg-soft: #0d1320;
  --panel: #111927;
  --panel-2: #0f1624;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e7edf8;
  --muted: #8b9bb5;
  --muted-2: #65748c;
  --accent: #6d5efc;
  --accent-2: #22d3ee;
  --ok: #10b981;
  --err: #f43f5e;
  --radius: 14px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(109, 94, 252, 0.18), transparent 60%),
    radial-gradient(700px 420px at 92% 0%, rgba(34, 211, 238, 0.10), transparent 62%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
a:hover { color: #fff; }

.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 22px;
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------------------------------------------------------------- 头部 */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 17, 0.78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 26px;
  height: 66px;
}

.brand { display: inline-flex; align-items: center; gap: 10px; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06101a;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.5px;
  box-shadow: 0 8px 22px -10px rgba(109, 94, 252, 0.9);
}

.brand-mark.small { width: 24px; height: 24px; font-size: 10px; border-radius: 7px; }

.brand-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand-text b { color: var(--accent-2); }

.nav { display: flex; gap: 4px; margin-right: auto; }

.nav-link {
  padding: 7px 13px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.nav-link.is-active { color: #fff; background: rgba(109, 94, 252, 0.18); }

.header-actions { display: flex; align-items: center; gap: 10px; }

.user-chip { display: inline-flex; align-items: center; gap: 8px; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(109, 94, 252, 0.22);
  border: 1px solid rgba(109, 94, 252, 0.45);
  font-size: 12px; color: #c8c2ff;
}
.user-name { font-size: 13px; color: var(--muted); max-width: 120px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #7a6bff, #5b4df0);
  color: #fff;
  box-shadow: 0 12px 28px -14px rgba(109, 94, 252, 0.95);
}
.btn-primary:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 16px 32px -14px rgba(109, 94, 252, 1); }

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line-strong);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); }

.btn-block { display: flex; width: 100%; }
.is-disabled { opacity: 0.45; pointer-events: none; }

.link { color: #a99cff; font-size: 13px; }
.link:hover { color: #c9c1ff; }
.link-danger { color: #ff8fa3; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: 13px; }
.link-danger:hover { color: #ffb3c2; }

/* ---------------------------------------------------------------- 提示 */

.flash {
  margin: 18px 0 0;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
}
.flash-ok { border-color: rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.10); color: #7fe3bb; }
.flash-error { border-color: rgba(244, 63, 94, 0.35); background: rgba(244, 63, 94, 0.10); color: #ffb0bd; }

/* ---------------------------------------------------------------- 首屏 */

.hero {
  padding: 66px 0 34px;
  text-align: center;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: 40px;
  line-height: 1.25;
  letter-spacing: -0.5px;
  font-weight: 800;
}
.accent {
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub { margin: 0 auto 26px; color: var(--muted); font-size: 15px; max-width: 620px; }

.search-form {
  display: flex;
  gap: 10px;
  max-width: 660px;
  margin: 0 auto;
}
.search-input {
  flex: 1;
  height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(13, 19, 32, 0.9);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input::placeholder { color: var(--muted-2); }
.search-input:focus {
  border-color: rgba(109, 94, 252, 0.75);
  box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.16);
}
.search-form .btn { height: 46px; padding: 0 26px; }

.hero-stats {
  margin-top: 20px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}
.hero-stats b { color: var(--text); font-weight: 700; }
.dot { color: var(--muted-2); }

/* ---------------------------------------------------------------- 筛选 */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.cat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-right: auto; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 13px;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.is-active {
  color: #fff;
  border-color: rgba(109, 94, 252, 0.6);
  background: rgba(109, 94, 252, 0.16);
}
.chip-count { font-size: 11px; color: var(--muted-2); }
.chip.is-active .chip-count { color: #cfc9ff; }

.sort-tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.sort-tab { padding: 5px 12px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.sort-tab:hover { color: var(--text); }
.sort-tab.is-active { background: rgba(109, 94, 252, 0.2); color: #fff; }

.result-tip { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.result-tip b { color: var(--accent-2); }

/* ---------------------------------------------------------------- 卡片 */

.source-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.source-card {
  display: flex;
  flex-direction: column;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 25, 39, 0.95), rgba(11, 17, 28, 0.95));
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.source-card:hover { transform: translateY(-3px); border-color: rgba(109, 94, 252, 0.45); }

.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }

.lang-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background: rgba(109, 94, 252, 0.16);
  color: #b9b1ff;
  border: 1px solid rgba(109, 94, 252, 0.32);
}
.lang-php { background: rgba(124, 82, 255, 0.16); color: #c4b5ff; border-color: rgba(124, 82, 255, 0.34); }
.lang-javascript, .lang-js { background: rgba(247, 223, 30, 0.12); color: #f2e06b; border-color: rgba(247, 223, 30, 0.28); }
.lang-python { background: rgba(55, 118, 171, 0.18); color: #8fc0e8; border-color: rgba(55, 118, 171, 0.36); }
.lang-vue { background: rgba(65, 184, 131, 0.14); color: #7fdbb2; border-color: rgba(65, 184, 131, 0.3); }
.lang-html { background: rgba(228, 77, 38, 0.14); color: #ffa48c; border-color: rgba(228, 77, 38, 0.3); }
.lang-go { background: rgba(0, 173, 216, 0.14); color: #7fdcf1; border-color: rgba(0, 173, 216, 0.3); }

.badge-hot {
  height: 22px; display: inline-flex; align-items: center; padding: 0 8px;
  border-radius: 6px; font-size: 11px; font-weight: 700;
  background: rgba(244, 63, 94, 0.14); color: #ff9aab; border: 1px solid rgba(244, 63, 94, 0.3);
}
.card-version { margin-left: auto; font-size: 12px; color: var(--muted-2); font-family: ui-monospace, Menlo, monospace; }

.card-title { margin: 0 0 8px; font-size: 16px; line-height: 1.45; font-weight: 700; }
.card-title a:hover { color: #cfc7ff; }

.card-summary {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.card-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 13px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--muted-2);
}
.tag { padding: 2px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.05); color: var(--muted); font-size: 11px; }
.card-stat { font-family: ui-monospace, Menlo, monospace; }
.card-time { margin-left: auto; }

/* ---------------------------------------------------------------- 空态 / 错误 */

.empty-state, .error-panel {
  text-align: center;
  padding: 70px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(13, 19, 32, 0.6);
  margin-bottom: 30px;
}
.empty-icon { font-size: 34px; color: var(--muted-2); margin-bottom: 10px; }
.empty-state h2, .error-panel h1 { margin: 0 0 8px; font-size: 20px; }
.empty-state p, .error-panel p { color: var(--muted); margin: 0 0 18px; }
.error-code { font-size: 48px; font-weight: 800; color: var(--accent); line-height: 1; margin-bottom: 10px; }

/* ---------------------------------------------------------------- 分页 */

.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 34px 0 10px; }
.page-btn {
  min-width: 36px; height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted); font-size: 13px;
}
.page-btn:hover { border-color: var(--line-strong); color: var(--text); }
.page-btn.is-active { background: rgba(109, 94, 252, 0.22); border-color: rgba(109, 94, 252, 0.55); color: #fff; }
.page-dots { color: var(--muted-2); }

/* ---------------------------------------------------------------- 详情页 */

.breadcrumb { display: flex; gap: 8px; align-items: center; padding: 22px 0 6px; font-size: 13px; color: var(--muted-2); flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }
.breadcrumb-current { color: var(--text); max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; padding: 8px 0 40px; }

.detail-main {
  padding: 26px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.detail-head { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.detail-title { margin: 0 0 10px; font-size: 27px; line-height: 1.35; letter-spacing: -0.3px; }
.detail-summary { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

.detail-body {
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: #c6d2e4;
  font-size: 14.5px;
  line-height: 1.85;
  word-break: break-word;
}

.repo-line { margin-top: 24px; font-size: 13px; color: var(--muted); word-break: break-all; }
.repo-line a { color: var(--accent-2); }

.detail-side { display: flex; flex-direction: column; gap: 16px; }

.download-panel {
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid rgba(109, 94, 252, 0.3);
  background: linear-gradient(180deg, rgba(109, 94, 252, 0.14), rgba(13, 19, 32, 0.9));
}
.dl-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.dl-desc { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.dl-meta { display: flex; gap: 14px; justify-content: center; margin-top: 14px; font-size: 12px; color: var(--muted-2); }

.info-panel { padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.info-row:last-child { border-bottom: 0; }
.info-row span { color: var(--muted-2); }
.info-row b { color: var(--text); font-weight: 600; }

.related { padding-bottom: 40px; }
.section-title { font-size: 18px; margin: 0 0 16px; }

/* ---------------------------------------------------------------- 登录注册 */

.auth-wrap { display: flex; justify-content: center; padding: 50px 22px 70px; }
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 30px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(17, 25, 39, 0.96), rgba(10, 15, 25, 0.96));
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 6px; font-size: 24px; }
.auth-sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.auth-foot { margin: 18px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.auth-foot a { color: var(--accent-2); }

/* ---------------------------------------------------------------- 表单 */

.field { display: block; margin-bottom: 16px; }
.field span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 12, 20, 0.85);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: rgba(109, 94, 252, 0.7);
  box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.14);
}
.field textarea { resize: vertical; line-height: 1.7; }
.field-tip { display: block; margin-top: 6px; font-size: 11.5px; color: var(--muted-2); font-style: normal; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.auth-form .btn { margin-top: 6px; height: 44px; }

/* ---------------------------------------------------------------- 后台 */

.admin-head { padding: 30px 0 20px; }
.admin-head h1 { margin: 0 0 4px; font-size: 24px; }
.admin-head p { margin: 0; color: var(--muted); font-size: 13px; }

.admin-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 18px; align-items: start; margin-bottom: 22px; }

.panel {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 22px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 17px; }

.admin-form .btn { height: 42px; }

.list-panel { margin-bottom: 50px; }
.table-wrap { overflow-x: auto; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
.admin-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.admin-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr:hover td { background: rgba(255, 255, 255, 0.02); }
.admin-table td a { color: #cfc7ff; }
.ops { display: flex; gap: 12px; align-items: center; }
.inline-form { display: inline; margin: 0; }

/* ---------------------------------------------------------------- 页脚 */

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: rgba(8, 12, 20, 0.6);
  padding: 30px 0;
}
.footer-inner { display: flex; flex-direction: column; gap: 10px; }
.footer-brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 14px; }
.footer-note { margin: 0; color: var(--muted-2); font-size: 12.5px; max-width: 760px; line-height: 1.7; }
.footer-copy { margin: 0; color: var(--muted-2); font-size: 12px; }

/* ---------------------------------------------------------------- 响应式 */

@media (max-width: 980px) {
  .source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-layout { grid-template-columns: 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .hero h1 { font-size: 32px; }
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .header-inner { height: 58px; gap: 12px; }
  .nav { display: none; }
  .user-name { display: none; }
  .brand-text { font-size: 15px; }
  .hero { padding: 40px 0 26px; }
  .hero h1 { font-size: 26px; }
  .hero-sub { font-size: 13.5px; }
  .source-grid, .grid-3 { grid-template-columns: 1fr; }
  .search-form { flex-direction: column; }
  .search-form .btn { width: 100%; }
  .filters { gap: 10px; }
  .detail-title { font-size: 21px; }
  .detail-main { padding: 20px; }
  .field-row { grid-template-columns: 1fr; }
  .auth-card { padding: 22px; }
  .page-btn { min-width: 32px; height: 32px; padding: 0 9px; font-size: 12px; }
}
