/* ============================================
   网址目录 - 完整扁平化样式
   主题：默认、珍珠灰、中国红、古典青、幻夜黑、天空蓝
   特点：紧凑卡片、智能分页、药丸徽章、手风琴侧栏
   ============================================ */

/* ---------- 默认主题 ---------- */
:root {
  --bg-body: #f8fafc;
  --bg-header: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06);
  --tag-bg: #f1f5f9;
  --tag-text: #475569;
  --meta-cat-bg: rgba(59, 130, 246, 0.12);
  --meta-cat-text: #3b82f6;
  --meta-reg-bg: rgba(59, 130, 246, 0.08);
  --meta-reg-text: #3b82f6;
  --radius: 4px;
  --transition: 0.2s ease;
}

[data-theme="pearl-grey"] {
  --bg-body: #f5f5f5;
  --bg-header: #fff;
  --bg-sidebar: #fff;
  --bg-card: #fff;
  --text: #1a1a1a;
  --primary: #333;
  --primary-hover: #000;
  --border: #d9d9d9;
  --tag-bg: #e6e6e6;
  --tag-text: #333;
  --meta-cat-bg: #e0e0e0;
  --meta-cat-text: #333;
  --meta-reg-bg: #e0e0e0;
  --meta-reg-text: #333;
}

[data-theme="china-red"] {
  --bg-body: #fef9f9;
  --bg-header: #fff;
  --bg-sidebar: #fff;
  --bg-card: #fff;
  --text: #2d1e1e;
  --primary: #b22222;
  --primary-hover: #8b1a1a;
  --border: #f0e3e3;
  --tag-bg: #fee2e2;
  --tag-text: #991b1b;
  --meta-cat-bg: rgba(178, 34, 34, 0.12);
  --meta-cat-text: #b22222;
  --meta-reg-bg: rgba(178, 34, 34, 0.08);
  --meta-reg-text: #b22222;
}

[data-theme="classical-cyan"] {
  --bg-body: #f5faf9;
  --bg-header: #fff;
  --bg-sidebar: #fff;
  --bg-card: #fff;
  --text: #1e3b3b;
  --primary: #0e7490;
  --primary-hover: #0a5c6e;
  --border: #e0f0f0;
  --tag-bg: #cffafe;
  --tag-text: #164e63;
  --meta-cat-bg: rgba(14, 116, 144, 0.12);
  --meta-cat-text: #0e7490;
  --meta-reg-bg: rgba(14, 116, 144, 0.08);
  --meta-reg-text: #0e7490;
}

[data-theme="night-black"] {
  --bg-body: #121212;
  --bg-header: #1e1e1e;
  --bg-sidebar: #1e1e1e;
  --bg-card: #1e1e1e;
  --text: #e0e0e0;
  --text-secondary: #a0a0a0;
  --primary: #bbb;
  --primary-hover: #fff;
  --border: #2c2c2c;
  --tag-bg: #2c2c2c;
  --tag-text: #bbb;
  --meta-cat-bg: rgba(187, 187, 187, 0.15);
  --meta-cat-text: #bbb;
  --meta-reg-bg: rgba(187, 187, 187, 0.1);
  --meta-reg-text: #bbb;
}

[data-theme="sky-blue"] {
  --bg-body: #f0f6ff;
  --bg-header: #fff;
  --bg-sidebar: #fff;
  --bg-card: #fff;
  --text: #1e2b4a;
  --primary: #1e40af;
  --primary-hover: #1e3a8a;
  --border: #dbeafe;
  --tag-bg: #dbeafe;
  --tag-text: #1e3a8a;
  --meta-cat-bg: rgba(30, 64, 175, 0.12);
  --meta-cat-text: #1e40af;
  --meta-reg-bg: rgba(30, 64, 175, 0.08);
  --meta-reg-text: #1e40af;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}
a {
  text-decoration: none;
  color: inherit;
}

/* 头部 */
.site-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
}
.logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}
.logo img {
  margin-top: 8px;
  height: 26px;
}
.header-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 0.9rem;
}
.datetime {
  display: flex;
  align-items: center;
  gap: 12px;
}
.time {
  font-weight: 600;
}
.lunar {
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.weather {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}
.weather-icon {
  font-size: 1.2rem;
}
.theme-selector select {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  border-radius: var(--radius);
}
.btn-submit {
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  display: inline-block;
  transition: background var(--transition);
  border-radius: var(--radius);
}
.btn-submit:hover {
  background: var(--primary-hover);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 150;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show {
  display: block;
}

.layout {
  max-width: 1400px;
  margin: 24px auto;
  display: flex;
  gap: 24px;
  padding: 0 20px;
  align-items: flex-start;
}
.sidebar {
  flex: 0 0 200px;
  position: sticky;
  top: 90px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  border-radius: var(--radius);
}
.main-content {
  flex: 1;
  min-width: 0;
}

/* 侧栏分类 */
.category-tree {
  list-style: none;
}
.cat-item {
  margin-bottom: 2px;
  border-radius: var(--radius);
}
.cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  background: transparent;
  border-radius: var(--radius);
  -webkit-tap-highlight-color: transparent;
}
.cat-header:hover {
  background: transparent !important;
}
.cat-link {
  flex: 1;
  display: block;
  padding: 10px 12px;
  font-weight: 500;
  color: var(--text);
  border-left: 3px solid transparent;
  text-decoration: none;
  line-height: 1.4;
  transition: color var(--transition), border-color var(--transition);
  background: transparent !important;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.cat-link:hover,
.cat-link:focus,
.cat-link:active {
  background: transparent !important;
  outline: none;
}
.cat-link.active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: transparent !important;
}
.cat-toggle {
  flex-shrink: 0;
  background: none !important;
  border: none;
  font-size: 0.7rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 10px 8px;
  margin: 0;
  line-height: 1;
  transition: transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.cat-toggle:hover {
  color: var(--primary);
  background: transparent !important;
}
.cat-item.expanded .cat-toggle {
  transform: rotate(90deg);
}
.tag-sublist {
  list-style: none;
  margin: 0 0 0 16px;
  padding: 0 0 0 12px;
  border-left: 1px solid var(--border);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s;
  background: transparent;
}
.cat-item.expanded .tag-sublist {
  max-height: 400px;
  opacity: 1;
}
.tag-sublist li {
  margin: 0;
  padding: 0;
}
.tag-sublist li a {
  display: block;
  padding: 6px 8px;
  font-size: 0.85rem;
  color: var(--tag-text);
  text-decoration: none;
  border-radius: calc(var(--radius) - 1px);
  transition: color var(--transition);
  background: transparent;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.tag-sublist li a:hover {
  color: var(--primary);
  background: transparent;
}
.tag-sublist li a.active {
  color: var(--primary);
  font-weight: 600;
  background: var(--tag-bg);
  border-radius: var(--radius);
}

/* 区域 */
.region-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 8px 16px;
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
}
.region-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.region-list a {
  padding: 6px 14px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  font-size: 0.85rem;
  border-radius: var(--radius);
}
.region-list a.active {
  background: var(--primary);
  color: #fff;
}

/* 搜索 */
.search-bar {
  margin-bottom: 20px;
}
.search-row {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
  overflow: hidden;
}
.engine-select-wrapper {
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-right: 1px solid var(--border);
}
.engine-select {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.search-input {
  flex: 1;
  border: none;
  padding: 12px 16px;
  font-size: 1rem;
  outline: none;
  background: transparent;
  color: var(--text);
}
.search-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}
.search-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0 24px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.search-btn:hover {
  background: var(--primary-hover);
}

/* 卡片网格 (紧凑) */
.website-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.site-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  color: var(--text);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s;
  position: relative;
  text-decoration: none;
}
.site-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.12);
  border-color: var(--primary);
}
.card-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
}
.card-body {
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.site-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 8px;
  line-height: 1.4;
  color: var(--text);
  position: relative;
  padding-bottom: 6px;
}
.site-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 30px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.2s;
}
.site-card:hover .site-title::after {
  width: 50px;
}
.site-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.meta-cat,
.meta-reg {
  font-size: 0.65rem;
  padding: 2px 8px;
  font-weight: 600;
  border-radius: 20px;
  line-height: 1.2;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.meta-cat {
  background: var(--meta-cat-bg);
  color: var(--meta-cat-text);
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
}
.meta-reg {
  background: var(--meta-reg-bg);
  color: var(--meta-reg-text);
  border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
}
.site-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.6rem;
  padding: 2px 7px;
  font-weight: 500;
  border-radius: 12px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.tag:hover {
  background: var(--primary);
  color: #fff;
}
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
  font-size: 1.2rem;
}

[data-theme="pearl-grey"] .card-accent {
  background: #999;
}
[data-theme="pearl-grey"] .site-title::after {
  background: #666;
}
[data-theme="pearl-grey"] .meta-cat,
[data-theme="pearl-grey"] .meta-reg {
  border-color: #ccc;
}

/* 智能分页 */
.pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 40px 0 20px;
  list-style: none;
  flex-wrap: wrap;
}
.pagination a,
.pagination span {
  padding: 6px 12px;
  font-size: 0.85rem;
}
.pagination a {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border-radius: var(--radius);
}
.pagination a.active,
.pagination a:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pager.dots {
  background: transparent;
  border: none;
  color: var(--text-secondary);
}

/* 页脚 */
.site-footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-header);
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.site-footer a {
  color: var(--primary);
}

/* 响应式 */
@media (max-width: 1200px) {
  .website-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 900px) {
  .website-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 768px) {
  .layout {
    flex-direction: column;
    padding: 0 12px;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    width: 260px;
    transform: translateX(-100%);
    z-index: 200;
    overflow-y: auto;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    border-radius: 0;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .menu-toggle {
    display: block;
  }
  .hide-mobile {
    display: none !important;
  }
  .header-meta {
    gap: 10px;
  }
  .website-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .search-row {
    flex-direction: column;
  }
  .engine-select-wrapper {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 14px;
  }
  .search-btn {
    width: 100%;
  }
  .logo img {
    margin-top: 10px;
    height: 20px;
  }
  .btn-submit {
    padding: 4px 8px;
    font-weight: 600;
    font-size: 0.75rem;
  }
}
/* ========== 防采集验证窗口 ========== */
.captcha-wall {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
  padding: 20px;
}
.captcha-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 30px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: center;
  max-width: 400px;
  width: 100%;
  margin: 20px auto;
}
.captcha-box h2 {
  margin-bottom: 10px;
  font-weight: 700;
  color: var(--text);
}
.captcha-box p {
  margin: 15px 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.captcha-box img {
  margin: 10px 0 15px;
  border: 1px solid var(--border);
  cursor: pointer;
}
.captcha-box .form-control {
  margin-bottom: 15px;
}
.captcha-box .btn-submit {
  width: 100%;
  padding: 10px;
  font-size: 1rem;
}

/* 错误提示 */
.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 15px;
  font-size: 0.9rem;
}
/* 验证码水平布局 */
.captcha-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}
.captcha-row img {
  flex-shrink: 0;
  height: 40px; /* 控制图片高度，与输入框一致 */
  border: 1px solid var(--border);
  cursor: pointer;
}
.captcha-row .form-control {
  flex: 1;
  margin-bottom: 0; /* 清除原有下边距 */
}
/* 推荐区块（仅标题） */
.featured-section {
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
  border-radius: var(--radius);
}
.featured-header {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
}
.featured-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.featured-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.featured-item {
  display: inline-block;
  padding: 4px 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background var(--transition), transform 0.15s;
  font-size: 0.88rem;
}
.featured-item:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}
