/* ============ 基础重置 ============ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #0d7d6c;
  --primary-light: #14a890;
  --primary-dark: #096556;
  --primary-bg: #f0faf8;
  --text: #1a2b2a;
  --text-light: #5a6b6a;
  --text-muted: #9aa8a7;
  --border: #e0e8e7;
  --bg: #f7faf9;
  --white: #ffffff;
  --shadow: 0 2px 8px rgba(13, 125, 108, 0.08);
  --shadow-hover: 0 6px 20px rgba(13, 125, 108, 0.15);
  --radius: 10px;
  --radius-sm: 6px;
}

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 { text-decoration: none; color: inherit; }
ul { list-style: none; }

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

/* ============ 头部 ============ */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.logo-icon {
  font-size: 26px;
}

.header-nav {
  display: flex;
  gap: 28px;
}

.nav-link {
  font-size: 15px;
  color: var(--text-light);
  transition: color 0.2s;
  position: relative;
}

.nav-link:hover { color: var(--primary); }
.nav-link.active { color: var(--primary); font-weight: 600; }
.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -22px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

/* ============ Hero ============ */
.hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  padding: 48px 0 56px;
  text-align: center;
  color: var(--white);
}

.hero-title {
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.hero-subtitle {
  font-size: 15px;
  opacity: 0.85;
  margin-bottom: 28px;
}

.search-box {
  display: flex;
  max-width: 560px;
  margin: 0 auto;
  gap: 0;
  background: var(--white);
  border-radius: 30px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 13px 24px;
  font-size: 15px;
  color: var(--text);
}

.search-btn {
  border: none;
  background: var(--primary);
  color: var(--white);
  padding: 0 32px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.search-btn:hover { background: var(--primary-dark); }

/* ============ 布局与侧边导航 ============ */
.layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.sidebar {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: 84px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 0;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
}

/* 滚动条美化 */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.sidebar-reset {
  border: none;
  background: none;
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.sidebar-reset:hover { background: var(--primary-bg); }

/* 导航分组 */
.nav-group { margin-bottom: 2px; }

.nav-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  border-radius: var(--radius-sm);
  margin: 0 6px;
}

.nav-group-title:hover { background: #f5f8f7; }

.nav-group-title .nav-group-icon {
  margin-right: 6px;
}

.nav-group-title .nav-arrow {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.nav-group.open .nav-arrow { transform: rotate(90deg); }

.nav-items {
  display: none;
  padding: 2px 6px 8px;
}

.nav-group.open .nav-items { display: block; }

.nav-item {
  display: flex;
  align-items: center;
  padding: 7px 12px 7px 30px;
  font-size: 13px;
  color: var(--text-light);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  user-select: none;
}

.nav-item:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: var(--white);
  font-weight: 500;
}

/* 内容区 */
.content {
  flex: 1;
  min-width: 0;
}

/* 当前筛选标签 */
.active-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.active-filters .af-label {
  font-size: 13px;
  color: var(--text-muted);
}

.active-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 13px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s;
}

.active-filter-chip:hover {
  background: #f0ece8;
  color: #c0392b;
}

.active-filter-chip .af-close {
  font-size: 11px;
  opacity: 0.7;
}

/* 资源卡片标签 */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: #f2f5f4;
  color: var(--text-light);
}

.card-tag.danger-tag {
  background: #fdf0ee;
  color: #c0392b;
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    position: static;
    width: 100%;
    max-height: none;
  }
}

/* ============ 分类筛选（旧版兼容） ============ */
.main-content {
  padding: 32px 20px 60px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 14px;
  color: var(--text-light);
  font-weight: 600;
}

.filter-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-tag {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: 20px;
  background: var(--white);
  color: var(--text-light);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.filter-tag:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-tag.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* ============ 资源卡片 ============ */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.resource-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.resource-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-category {
  flex-shrink: 0;
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 12px;
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 500;
  white-space: nowrap;
}

.card-desc {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 42px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.card-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.card-meta span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.card-download {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.card-format {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  background: #e8f5f2;
  color: var(--primary);
}

/* ============ 弹窗 ============ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.show {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-box {
  background: var(--white);
  border-radius: 14px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 350px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: #f0f0f0;
  color: var(--text);
}

.modal-body {
  padding: 0;
}

/* ============ 广告区域 ============ */
.ad-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #fcfcfc;
}

.ad-link {
  display: block;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}

.ad-link:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ad-image {
  width: 100%;
  display: block;
  max-height: 160px;
  object-fit: cover;
}

.ad-code-block {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-code-block:empty {
  display: none;
}

.ad-text-block {
  padding: 14px 16px;
  text-align: center;
  position: relative;
}

.ad-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 10px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
}

.ad-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.ad-subtitle {
  font-size: 13px;
  color: var(--text-light);
}

/* ============ 资源详情 ============ */
.resource-detail {
  padding: 18px 20px 20px;
}

.resource-info {
  display: flex;
  gap: 20px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.info-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-label {
  font-size: 12px;
  color: var(--text-muted);
}

.info-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.resource-description {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.7;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: #f8f9f9;
  border-radius: var(--radius-sm);
}

.link-section {
  margin-bottom: 18px;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.link-label {
  font-size: 14px;
  color: var(--text-light);
  width: 60px;
  flex-shrink: 0;
}

.link-value-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.link-value {
  flex: 1;
  font-size: 13px;
  color: var(--primary);
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: 2px;
  font-family: 'Courier New', monospace;
}

.copy-btn {
  flex-shrink: 0;
  padding: 5px 14px;
  font-size: 12px;
  border: 1px solid var(--primary);
  background: var(--white);
  color: var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.copy-btn:hover {
  background: var(--primary);
  color: var(--white);
}

.copy-btn.copied {
  background: var(--primary);
  color: var(--white);
}

.download-btn {
  display: block;
  text-align: center;
  padding: 13px;
  background: var(--primary);
  color: var(--white);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s;
}

.download-btn:hover {
  background: var(--primary-dark);
}

/* ============ 加载和空状态 ============ */
.loading-state,
.empty-state,
.detail-loading {
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
}

.detail-loading {
  padding: 40px 0;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: var(--white);
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 2000;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ 页脚 ============ */
.site-footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 28px 0;
  text-align: center;
}

.site-footer p {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.footer-note {
  font-size: 12px !important;
  color: var(--text-muted) !important;
}

/* ============ 响应式 ============ */
@media (max-width: 640px) {
  .hero-title { font-size: 24px; }
  .hero-subtitle { font-size: 13px; }
  .header-nav { gap: 16px; }
  .nav-link { font-size: 14px; }
  .resource-grid { grid-template-columns: 1fr; }
  .modal-box { max-width: 100%; }
  .resource-info { flex-wrap: wrap; gap: 12px; }
  .logo-text { font-size: 18px; }
}
