/* ================= 基础与主题变量 ================= */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1b2333;
  --muted: #667085;
  --border: #e5e9f2;
  --primary: #4f6ef7;
  --primary-2: #7c5cff;
  --primary-soft: #eef2ff;
  --shadow: 0 8px 24px rgba(27, 35, 51, .08);
  --radius: 14px;
}
html[data-theme="dark"] {
  --bg: #0e1320;
  --card: #161d2e;
  --text: #e9edf7;
  --muted: #94a0b8;
  --border: #263050;
  --primary-soft: #1c2742;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

html { scroll-behavior: smooth; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background .3s, color .3s;
}
.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }
a { color: inherit; text-decoration: none; }
main { min-height: 60vh; padding-bottom: 40px; }

/* ================= 按钮 ================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 600; transition: .2s;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; box-shadow: 0 4px 14px rgba(79, 110, 247, .35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(79, 110, 247, .45); }
.btn-ghost { border: 1px solid var(--border); background: var(--card); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; justify-content: center; margin-top: 18px; }

/* ================= 导航 ================= */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; gap: 32px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; flex: none; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-weight: 700; font-size: 17px;
  display: grid; place-items: center;
}
.logo-text { font-size: 18px; font-weight: 700; }
.logo-text small { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.nav-links { display: flex; gap: 26px; flex: 1; }
.nav-links a { font-size: 15px; color: var(--muted); padding: 4px 2px; position: relative; transition: .2s; }
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--primary); font-weight: 600; }
.nav-links a.active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -4px;
  height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
}
.nav-actions { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card);
  display: grid; place-items: center; transition: .2s;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn svg { width: 18px; height: 18px; }
html[data-theme="light"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }

/* ================= Hero ================= */
.hero {
  padding: 76px 0 64px; text-align: center;
  background:
    radial-gradient(600px 300px at 20% 10%, rgba(79,110,247,.14), transparent 60%),
    radial-gradient(600px 300px at 80% 0%, rgba(124,92,255,.12), transparent 60%);
}
.hero h1 { font-size: 44px; line-height: 1.25; letter-spacing: 1px; }
.grad {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { margin: 16px 0 30px; color: var(--muted); font-size: 16px; }
.hero-search {
  max-width: 620px; margin: 0 auto; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 6px 6px 20px; box-shadow: var(--shadow);
}
.hero-search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.hero-search input { flex: 1; border: none; outline: none; background: none; font-size: 15px; }
.hero-stats { display: flex; justify-content: center; gap: 60px; margin-top: 44px; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats b {
  font-size: 28px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-stats span { font-size: 13px; color: var(--muted); }

/* ================= 区块标题 ================= */
.section-head { margin: 52px 0 22px; }
.section-head h2 { font-size: 24px; }
.section-head p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.section-head.row { display: flex; align-items: flex-end; justify-content: space-between; }
.link-more { color: var(--primary); font-size: 14px; font-weight: 600; }
.link-more:hover { text-decoration: underline; }
/* ================= 分类卡片 ================= */
.category-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
.cat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 20px;
  display: flex; flex-direction: column; gap: 6px;
  transition: .25s; cursor: pointer;
}
.cat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--primary); }
.cat-icon {
  width: 44px; height: 44px; border-radius: 11px;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; margin-bottom: 6px;
}
.cat-icon svg { width: 24px; height: 24px; }
.cat-card h3 { font-size: 16px; }
.cat-card p { font-size: 12.5px; color: var(--muted); }
.cat-card .cat-count { font-size: 12px; color: var(--primary); font-weight: 600; margin-top: 4px; }

/* ================= 资料卡片 ================= */
.resource-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
.res-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  transition: .25s; cursor: pointer;
}
.res-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--primary); }
.res-top { display: flex; align-items: center; justify-content: space-between; }
.badge {
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 999px; letter-spacing: .5px;
}
.badge-pdf   { background: #fdecec; color: #e14b4b; }
.badge-doc   { background: #e8f0fe; color: #3b6fe0; }
.badge-ppt   { background: #fff3e2; color: #e08a2e; }
.badge-video { background: #e9f9ee; color: #2ba05a; }
.badge-zip   { background: #f3eafd; color: #8a55e0; }
html[data-theme="dark"] .badge-pdf   { background: #3d2020; }
html[data-theme="dark"] .badge-doc   { background: #1c2c4d; }
html[data-theme="dark"] .badge-ppt   { background: #3d2f18; }
html[data-theme="dark"] .badge-video { background: #17351f; }
html[data-theme="dark"] .badge-zip   { background: #2d2145; }
.res-size { font-size: 12px; color: var(--muted); }
.res-card h3 { font-size: 15.5px; line-height: 1.45; }
.res-card .res-desc {
  font-size: 13px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.res-meta {
  display: flex; align-items: center; gap: 14px;
  font-size: 12.5px; color: var(--muted); margin-top: auto;
  padding-top: 10px; border-top: 1px dashed var(--border);
}
.res-meta .star { color: #f5a623; font-weight: 700; }
.res-meta span { display: inline-flex; align-items: center; gap: 4px; }
.res-meta svg { width: 13px; height: 13px; }

/* ================= 资料库工具栏 ================= */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; }
.search-box {
  flex: 1; min-width: 240px; display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 14px; height: 42px;
}
.search-box:focus-within { border-color: var(--primary); }
.search-box svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.search-box input { flex: 1; border: none; outline: none; background: none; }
.select {
  height: 42px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); outline: none; cursor: pointer;
}
.select:focus { border-color: var(--primary); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 6px; }
.chip {
  padding: 6px 16px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--muted); transition: .2s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent; color: #fff; font-weight: 600;
}
.result-meta { font-size: 13px; color: var(--muted); margin: 10px 0 16px; }

.empty { text-align: center; padding: 70px 0; color: var(--muted); }
.empty svg { width: 52px; height: 52px; margin-bottom: 12px; opacity: .5; }
/* ================= 弹窗 ================= */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-mask { position: absolute; inset: 0; background: rgba(10, 14, 26, .55); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto;
  background: var(--card); border-radius: 16px; padding: 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.94) translateY(10px); opacity: 0; } }
.modal-close {
  position: absolute; top: 14px; right: 16px;
  font-size: 24px; color: var(--muted); line-height: 1; padding: 4px 8px; border-radius: 8px;
}
.modal-close:hover { color: var(--text); background: var(--bg); }

/* 详情弹窗内容 */
.detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.detail-cat { font-size: 12px; color: var(--primary); font-weight: 600; background: var(--primary-soft); padding: 3px 10px; border-radius: 999px; }
.detail-card h3 { font-size: 20px; line-height: 1.4; margin-bottom: 10px; padding-right: 30px; }
.detail-desc { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.detail-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  background: var(--bg); border-radius: 12px; padding: 14px; margin-bottom: 18px;
}
.detail-stats div { text-align: center; }
.detail-stats b { display: block; font-size: 15px; }
.detail-stats span { font-size: 11.5px; color: var(--muted); }
.detail-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.detail-tags span {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px;
}
.detail-uploader { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.detail-uploader b { color: var(--text); }

/* ================= 表单 ================= */
.form-title { font-size: 20px; margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-group input[type="text"],
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); outline: none; transition: .2s;
}
.form-group :is(input, select, textarea):focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.file-input { display: flex; align-items: center; gap: 12px; }
.file-input .file-name { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================= 关于页 ================= */
.about-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.about-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px 22px;
}
.about-card h3 { font-size: 17px; margin-bottom: 8px; color: var(--primary); }
.about-card p { font-size: 14px; color: var(--muted); }
.about-notice {
  margin-top: 20px; padding: 22px; border-radius: var(--radius);
  border: 1px dashed var(--border); background: var(--card);
}
.about-notice h3 { font-size: 15px; margin-bottom: 6px; }
.about-notice p { font-size: 13.5px; color: var(--muted); }

/* ================= 页脚 ================= */
.footer { border-top: 1px solid var(--border); padding: 30px 0; margin-top: 30px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand p { font-size: 12.5px; color: var(--muted); }
.footer-copy { font-size: 12.5px; color: var(--muted); }

/* ================= Toast 与回到顶部 ================= */
.toast {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 11px 24px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow); z-index: 200; animation: toastIn .3s ease;
  max-width: 86vw; text-align: center;
}
@keyframes toastIn { from { transform: translate(-50%, 16px); opacity: 0; } }
.back-top {
  position: fixed; right: 26px; bottom: 26px; z-index: 90;
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--border);
  display: grid; place-items: center; box-shadow: var(--shadow); transition: .2s;
}
.back-top:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); }
.back-top svg { width: 18px; height: 18px; }

/* ================= 响应式 ================= */
@media (max-width: 960px) {
  .category-grid { grid-template-columns: repeat(3, 1fr); }
  .resource-grid { grid-template-columns: repeat(2, 1fr); }
  .about-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .nav-inner { gap: 14px; }
  .nav-links { gap: 16px; }
  .nav-links a { font-size: 14px; }
  .logo-text small { display: none; }
  .nav-actions .btn { padding: 8px 12px; font-size: 13px; }
  .nav-actions .btn svg { display: none; }
  .hero { padding: 52px 0 44px; }
  .hero h1 { font-size: 30px; }
  .hero-stats { gap: 34px; }
  .hero-search { flex-wrap: wrap; border-radius: 16px; padding: 10px; }
  .hero-search input { width: 100%; padding: 4px 6px; }
  .hero-search .btn { width: 100%; justify-content: center; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .resource-grid { grid-template-columns: 1fr; }
  .detail-stats { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .modal-card { padding: 22px; }
}

/* ================= 登录状态 / 评分 / 认证弹窗 ================= */
.user-info { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.user-info .btn { padding: 8px 14px; font-size: 13px; }
.auth-tabs { margin: 0 0 18px; }
.rate-row { display: flex; align-items: center; gap: 4px; font-size: 13.5px; color: var(--muted); margin-bottom: 18px; }
.rate-star { font-size: 22px; line-height: 1; color: #c9d2e3; transition: .15s; padding: 0 2px; }
.rate-star:hover { color: #f5a623; transform: scale(1.18); }
@media (max-width: 640px) {
  .user-info #userName { display: none; }
  #authBtn { padding: 8px 12px; font-size: 13px; }
}

/* ================= 收藏 ================= */
.chips-extra { margin-top: -8px; }
.detail-actions { display: flex; gap: 10px; }
.detail-actions .btn-primary { flex: 1; justify-content: center; }
#favBtn.faved { color: #f5a623; border-color: #f5a623; background: rgba(245, 166, 35, .08); }
.res-meta .fav-count { color: #e05c7a; }

/* ================= 评论区 ================= */
.comments { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 16px; }
.comments h4 { font-size: 15px; margin-bottom: 12px; }
.comments h4 span { color: var(--muted); font-weight: 500; font-size: 13px; }
.comment-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.comment-item { background: var(--bg); border-radius: 10px; padding: 10px 14px; }
.comment-head { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.comment-head b { color: var(--text); font-size: 13px; }
.comment-item p { font-size: 13.5px; word-break: break-word; }
.comment-del { margin-left: auto; font-size: 12px; color: #e14b4b; flex: none; }
.comment-del:hover { text-decoration: underline; }
.comment-form { display: flex; gap: 8px; }
.comment-form input {
  flex: 1; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); outline: none;
}
.comment-form input:focus { border-color: var(--primary); }
.comment-loading { font-size: 13px; color: var(--muted); text-align: center; padding: 12px 0; }

/* ================= 管理员后台 ================= */
.admin-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 10px; text-align: center;
}
.stat-card b {
  display: block; font-size: 22px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-card span { font-size: 12.5px; color: var(--muted); }
.admin-tabs { margin: 0 0 16px; }
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); background: var(--card); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
.admin-table th, .admin-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table th { background: var(--bg); font-size: 12.5px; color: var(--muted); font-weight: 600; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table td.ellipsis { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.admin-action { font-size: 12.5px; color: var(--primary); margin-right: 12px; }
.admin-action:last-child { margin-right: 0; }
.admin-action:hover { text-decoration: underline; }
.admin-action.danger { color: #e14b4b; }
.role-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.role-admin { background: #fff3e2; color: #e08a2e; }
.role-user { background: var(--primary-soft); color: var(--primary); }
@media (max-width: 960px) { .admin-stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) {
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .comment-form { flex-direction: column; }
}
