:root {
  --bg: #0f172a;
  --panel: #111827;
  --muted: #94a3b8;
  --text: #e5e7eb;
  --accent: #22c55e;
  --card: #0b1220;
  --border: #1f2937;
  --shadow: 0 6px 24px rgba(0,0,0,.25);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc;
    --panel: #ffffff;
    --muted: #64748b;
    --text: #0f172a;
    --accent: #16a34a;
    --card: #ffffff;
    --border: #e5e7eb;
    --shadow: 0 8px 24px rgba(15, 23, 42, .12);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, rgba(34,197,94,.08), transparent 40%),
              radial-gradient(1200px 600px at 110% -20%, rgba(59,130,246,.08), transparent 40%),
              var(--bg);
}

/* Layout */
.container { width: min(1200px, 92%); margin-inline: auto; }

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: linear-gradient(120deg, #22c55e, #3b82f6);
  backdrop-filter: saturate(1.1) blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  height: 80px; /* 设置导航条高度为80px */
}
.site-header .container {
  display: flex;
  flex-direction: column;
  justify-content: center; /* 在容器中垂直居中 */
  height: 100%; /* 确保占满容器高度 */
  gap: 0; /* 移除间隙 */
}

.header-top {
  display: none; /* 隐藏顶部标题区域 */
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: center; /* 水平居中 */
  height: 100%;
  padding: 0 10px; /* 调整内边距 */
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between; /* 左右分布，中间留空 */
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
  height: 100%; /* 确保填满容器高度 */
}

.site-nav .nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* 添加用于包含右侧按钮的容器 */
.admin-links-container {
  display: flex;
  gap: 4px; /* 右侧按钮之间使用更小的间距 */
}

.category-link {
  color: #333;
  text-decoration: none;
  font-size: 16px; /* 增大字体大小 */
  padding: 10px 16px;
  border-radius: 16px;
  font-weight: 600; /* 加粗字体 */
  transition: all 0.3s ease;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  background: white;
  border: 2px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px; /* 设置固定高度确保垂直居中 */
}

.category-link:before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1), transparent);
  transition: 0.5s;
}

.category-link:hover:before {
  left: 100%;
}

.category-link:hover {
  color: #000;
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.category-link:active {
  transform: translateY(0);
}

.category-link.active {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.admin-link {
  color: white;
  text-decoration: none;
  font-size: 16px; /* 增大字体大小 */
  padding: 10px 16px;
  border-radius: 16px;
  font-weight: 600; /* 加粗字体 */
  transition: all 0.3s ease;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px; /* 设置固定高度确保垂直居中 */
}

.admin-link:before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: 0.5s;
}

.admin-link:hover:before {
  left: 100%;
}

.admin-link:hover {
  background: rgba(0, 0, 0, 0.3);
  color: #f0f0f0;
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.admin-link:active {
  transform: translateY(0);
}

/* Adjust main content to account for fixed header */
main {
  margin-top: 80px; /* 调整主内容的上边距以适应80px高度的导航条 */
}

/* Search section */
.search-section {
  padding: 30px 0 20px 0; /* 增加上边距10px，从20px增加到30px */
}

.search-container {
  display: flex;
  gap: 20px;
  align-items: center;
  max-width: 100%;
  margin: 0 auto;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 768px) {
  .search-container {
    flex-direction: column;
  }
  
  .search-bar input, .title-search-container input {
    width: 100% !important;
    max-width: 100% !important;
  }
}

.baidu-logo {
  height: 40px; /* 调整logo高度为40px */
  object-fit: contain;
  margin-right: 10px; /* 在logo和搜索框之间增加10px间距 */
}

.search-bar {
  display: flex;
  gap: 0; /* 移除默认gap，使用margin控制间距 */
  align-items: center;
  width: fit-content;
  min-width: fit-content;
}

.search-bar input {
  flex: 1;
  padding: 10px 16px; /* 调整padding以适配40px高度 */
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  font-size: 16px;
  width: 400px; /* 百度搜索输入框宽度 */
  max-width: 400px;
  height: 40px; /* 调整高度为40px */
  box-sizing: border-box; /* 包含padding在高度计算内 */
  margin-right: 10px; /* 与按钮之间增加间距 */
}

.search-bar button {
  padding: 10px 20px; /* 调整padding以适配40px高度 */
  border-radius: 16px;
  border: 2px solid white;
  background: linear-gradient(120deg, #22c55e, #3b82f6);
  color: white;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  min-width: 50px; /* 确保按钮有最小宽度 */
  width: auto;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  height: 40px; /* 调整高度为40px */
  box-sizing: border-box; /* 包含padding在高度计算内 */
}

.title-search-container {
  display: flex;
  gap: 10px;
  align-items: center;
  width: fit-content;
  min-width: fit-content;
}

.title-search-container input {
  flex: 1;
  padding: 10px 16px; /* 调整padding以适配40px高度 */
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  font-size: 16px;
  width: 200px; /* 标题搜索输入框宽度 */
  max-width: 200px;
  height: 40px; /* 调整高度为40px */
  box-sizing: border-box; /* 包含padding在高度计算内 */
  margin-right: 10px; /* 与按钮之间增加间距 */
}

.title-search-container button {
  padding: 10px 20px; /* 调整padding以适配40px高度 */
  border-radius: 16px;
  border: 2px solid white;
  background: linear-gradient(120deg, #22c55e, #3b82f6);
  color: white;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  min-width: 50px; /* 确保按钮有最小宽度 */
  width: auto;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  height: 40px; /* 调整高度为40px */
  box-sizing: border-box; /* 包含padding在高度计算内 */
}

/* 高亮显示匹配的链接标题 */
.highlight {
  background-color: #a78bfa; /* 紫色背景 */
  color: white;
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: bold;
}

/* Category */
.category { 
  margin-top: 36px;
  scroll-margin-top: 160px; /* 为固定头部留出空间 */
}
.category-title {
  font-size: 22px; 
  margin: 0 0 18px; 
  color: var(--text);
  font-weight: 600;
  position: relative;
  padding-bottom: 10px;
  display: inline-block;
}

.category-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #3b82f6);
  border-radius: 3px;
}

/* Grid of links */
.links-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 18px;
}
@media (max-width: 1200px) { .links-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1024px) { .links-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .links-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px)  { .links-grid { grid-template-columns: 1fr; } }

.link-card {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--border); background: var(--card);
  border-radius: 16px; padding: 18px; text-decoration: none;
  color: var(--text); box-shadow: var(--shadow); 
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.link-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 4px;
  background: linear-gradient(90deg, var(--accent), #3b82f6);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}
.link-card:hover { 
  transform: translateY(-4px);
  border-color: color-mix(in oklab, var(--accent) 60%, var(--border));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}
.link-card:hover::before {
  transform: translateX(0);
}

.link-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.link-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.link-favicon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  overflow: hidden;
}

.link-title { 
  font-weight: 600; 
  font-size: 16px;
  margin-top: 0;
}

.link-url { 
  color: var(--muted); 
  font-size: 13px; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  white-space: nowrap;
  margin-top: 4px;
}

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; }
.site-footer p { color: var(--muted); font-size: 13px; }

/* Helpers */
.empty { color: var(--muted); padding: 20px 0; }
.empty.small { padding: 8px 0; font-size: 14px; }

/* Admin basic */
.admin-wrap { padding: 24px 0 40px; }
.admin-card {
  background: color-mix(in oklab, var(--panel) 98%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.admin-grid { display: grid; gap: 14px; grid-template-columns: repeat(12, 1fr); }
.field { display: flex; flex-direction: column; gap: 6px; }
input[type="text"], input[type="number"], input[type="url"], input[type="password"], select {
  padding: 11px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, transform .08s ease;
}
input[type="text"]:focus, input[type="number"]:focus, input[type="url"]:focus, input[type="password"]:focus, select:focus {
  border-color: color-mix(in oklab, var(--accent) 65%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent);
  transform: translateY(-1px);
}
label { font-size: 13px; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer; text-decoration: none;
  font-weight: 600; user-select: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .08s ease, box-shadow .15s ease;
}
.btn:hover { border-color: color-mix(in oklab, var(--accent) 45%, var(--border)); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--accent); color: #fff; border-color: transparent;
  box-shadow: 0 6px 16px color-mix(in oklab, var(--accent) 25%, transparent);
}
.btn.primary:hover { filter: brightness(0.95); }
.btn.danger {
  background: #ef4444; color: #fff; border-color: transparent;
  box-shadow: 0 6px 16px rgba(239,68,68,.25);
}
.btn.danger:hover { filter: brightness(0.95); }
.btn.ghost {
  background: transparent; color: var(--text);
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table thead th {
  position: sticky; top: 60px;
  background: color-mix(in oklab, var(--panel) 96%, transparent);
  color: var(--muted); font-size: 13px; letter-spacing: .2px;
  border-bottom: 1px solid var(--border); backdrop-filter: blur(6px);
}
.table th, .table td { padding: 12px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.table tbody tr:nth-child(odd) { background: color-mix(in oklab, var(--panel) 6%, transparent); }
.table tbody tr:hover { background: color-mix(in oklab, var(--accent) 8%, transparent); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; color: #fff; background: var(--accent); }

/* Color picker styles */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.color-option {
  display: block;
  position: relative;
}

.color-option input {
  position: absolute;
  opacity: 0;
}

.color-block {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.color-default {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid var(--border);
  cursor: pointer;
  background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 10px 10px;
  transition: all 0.2s ease;
  font-size: 12px;
  color: #666;
}

.color-option input:checked + .color-block,
.color-option input:checked + .color-default {
  border-color: var(--accent);
  transform: scale(1.1);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 30%, transparent);
}

.color-option input:focus + .color-block,
.color-option input:focus + .color-default {
  outline: 2px solid var(--accent);
}

/* Inline color picker for table */
.color-picker-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.color-option-inline {
  display: block;
  position: relative;
}

.color-option-inline input {
  position: absolute;
  opacity: 0;
}

.color-block-inline {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.color-default-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 8px 8px;
  transition: all 0.2s ease;
  font-size: 10px;
  color: #666;
}

.color-option-inline input:checked + .color-block-inline,
.color-option-inline input:checked + .color-default-inline {
  border-color: var(--accent);
  transform: scale(1.1);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 30%, transparent);
}
, var(--accent) 30%, transparent);
}
