:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-weak: #eff4ff;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 18px rgba(16, 24, 40, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

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

a { color: inherit; text-decoration: none; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 18px; }

/* ===== 顶部 ===== */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header .container {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
}
.logo { font-size: 19px; font-weight: 800; color: var(--primary); white-space: nowrap; }
.logo small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 6px; }

.search {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  max-width: 520px;
}
.search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
  color: var(--text);
}
.search svg { width: 18px; height: 18px; fill: var(--muted); flex: none; }

.admin-link { font-size: 14px; color: var(--muted); white-space: nowrap; }
.admin-link:hover { color: var(--primary); }

/* ===== 横幅 ===== */
.banner {
  margin: 22px 0 8px;
  background: linear-gradient(120deg, #2563eb, #7c3aed);
  color: #fff;
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: var(--shadow);
}
.banner h1 { margin: 0 0 6px; font-size: 24px; }
.banner p { margin: 0; opacity: .92; font-size: 14px; }

.notice {
  margin: 14px 0;
  font-size: 13px;
  color: var(--muted);
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 10px 14px;
}

/* ===== 分类筛选 ===== */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 6px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 12px;
  flex-wrap: wrap;
  gap: 10px;
}
.toolbar .count { color: var(--muted); font-size: 14px; }
.sort select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}

/* ===== 资源网格 ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 18px;
  padding-bottom: 40px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
  display: flex;
  flex-direction: column;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(16,24,40,.12); }
.card .cover { position: relative; aspect-ratio: 4 / 3; background: #eef2f7; }
.card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .pan-badge {
  position: absolute; top: 10px; left: 10px;
  color: #fff; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
}
.card .hot {
  position: absolute; top: 10px; right: 10px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px;
  padding: 3px 9px; border-radius: 999px;
}
.card .body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; }
.card .title { font-size: 15px; font-weight: 700; margin: 0 0 8px; line-height: 1.4; }
.card .meta { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.card .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.card .tag {
  font-size: 12px; color: var(--primary);
  background: var(--primary-weak); border-radius: 6px; padding: 2px 8px;
}
.card .pw { font-size: 12px; color: #b45309; margin-top: 8px; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* ===== 详情页 ===== */
.detail-wrap { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; padding: 26px 0 50px; }
.detail-cover img { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow); }
.detail-info h1 { font-size: 26px; margin: 0 0 12px; }
.detail-info .row { display: flex; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.detail-info .label { color: var(--muted); font-size: 14px; min-width: 64px; }
.detail-info .desc { color: #374151; font-size: 15px; margin: 16px 0; }
.detail-info .actions { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; cursor: pointer; border-radius: 10px;
  padding: 11px 20px; font-size: 15px; font-weight: 600;
  transition: filter .15s ease;
}
.btn:hover { filter: brightness(.95); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--primary); border: 1px solid var(--primary); }
.pw-box {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff7ed; border: 1px dashed #fdba74;
  border-radius: 8px; padding: 6px 12px; font-size: 14px;
}
.pw-box b { color: #b45309; letter-spacing: 1px; }

.back { color: var(--muted); font-size: 14px; display: inline-block; margin: 18px 0 0; }

/* ===== 后台 ===== */
.login-box { max-width: 360px; margin: 120px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow); }
.login-box h2 { margin: 0 0 16px; text-align: center; }
.login-box input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; font-size: 15px; margin-bottom: 14px; }
.login-box button { width: 100%; }

.admin-panel { padding: 24px 0 60px; }
.admin-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.admin-toolbar h2 { margin: 0; font-size: 20px; flex: 1; }
table.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.admin-table th, table.admin-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
table.admin-table th { background: #f8fafc; color: var(--muted); font-weight: 600; }
table.admin-table tr:last-child td { border-bottom: none; }
.mini-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 5px 12px; cursor: pointer; font-size: 13px; margin-right: 6px; }
.mini-btn:hover { border-color: var(--primary); color: var(--primary); }
.mini-btn.danger:hover { border-color: #ef4444; color: #ef4444; }

.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-mask.show { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 26px; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 12px; font-size: 14px; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 70px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

/* ===== 页脚 ===== */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 22px 0; color: var(--muted); font-size: 13px; text-align: center; }
.site-footer .container > div + div { margin-top: 6px; }
.site-footer .beian a { color: var(--muted); text-decoration: none; }
.site-footer .beian a:hover { color: var(--primary); text-decoration: underline; }

/* ===== 响应式 ===== */
@media (max-width: 860px) {
  .detail-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .site-header .container { height: 56px; }
  .logo small { display: none; }
  .banner { padding: 20px; }
  .banner h1 { font-size: 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-toolbar h2 { font-size: 17px; }
  table.admin-table { font-size: 13px; }
}
