/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;600;900&display=swap');

/* ===== CSS 变量 ===== */
:root {
  --glass-bg: rgba(0, 0, 0, 0.45);
  --glass-border: rgba(255, 255, 255, 0.25);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --primary: #4CAF50;
  --primary-dim: rgba(76, 175, 80, 0.35);
  --text-main: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.80);
  --radius-card: 14px;
  --radius-section: 20px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; outline: none; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Noto Sans SC', sans-serif;
  color: var(--text-main);
  min-height: 100vh;
  background: #1a1a1a;
  overflow-x: hidden;
}

/* ===== 背景层 ===== */
#bgLayer {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

#bgOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: -1;
}

/* ===== 主容器 ===== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.2rem;
  width: 100%;
}

/* ===== 头部 ===== */
.header-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 1.5rem;
  width: 100%;
  overflow: hidden;
}

.header-icon {
  font-size: 2rem;
  flex-shrink: 0;
  filter: drop-shadow(0 0 12px rgba(76, 175, 80, 0.8)) drop-shadow(0 4px 8px rgba(0,0,0,0.6));
  animation: float 3s ease-in-out infinite;
  user-select: none;
  display: flex;
  align-items: center;
}
.header-icon:last-child { animation-delay: 1.5s; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

h1 {
  text-align: center;
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  white-space: nowrap;
  background: linear-gradient(135deg, #ffffff 0%, #a8f5ab 30%, #4CAF50 55%, #81e085 75%, #ffffff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter:
    drop-shadow(0 0 20px rgba(76, 175, 80, 0.7))
    drop-shadow(0 0 40px rgba(76, 175, 80, 0.35))
    drop-shadow(0 6px 16px rgba(0, 0, 0, 0.8));
}

h1::after {
  content: '';
  display: block;
  margin: 8px auto 0;
  width: 60%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #4CAF50, rgba(76,175,80,0.5), transparent);
  border-radius: 2px;
}

.header-subtitle {
  text-align: center;
  font-size: clamp(0.6rem, 1.5vw, 0.78rem);
  letter-spacing: 0.25em;
  color: rgba(255,255,255,0.68);
  text-transform: uppercase;
  margin-top: 5px;
  font-weight: 400;
}

/* ===== 搜索区域 ===== */
.search-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
  gap: 10px;
  width: 100%;
}

/* ===== 分类 Tab ===== */
.search-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.search-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.93rem;
  font-weight: 700;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}

.search-tab:hover {
  background: rgba(76,175,80,0.15);
  border-color: rgba(76,175,80,0.4);
  color: #fff;
}

.search-tab.active {
  background: rgba(76,175,80,0.28);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 12px rgba(76,175,80,0.35);
}

.tab-icon { font-size: 1.1rem; }
.tab-label { font-size: 1rem; }

/* ===== 搜索框 ===== */
.search-box {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 2px solid var(--glass-border);
  border-radius: 50px;
  padding: 5px 8px 5px 6px;
  box-shadow: var(--glass-shadow);
  width: 100%;
  max-width: 700px;
  min-width: 0;
  gap: 8px;
  position: relative;
}

/* ===== 引擎触发器（左侧可点击区域） ===== */
.engine-trigger {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 30px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.07);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.18s, border-color 0.18s;
  flex-shrink: 0;
  user-select: none;
  white-space: nowrap;
}

.engine-trigger:hover {
  background: rgba(76,175,80,0.18);
  border-color: rgba(76,175,80,0.5);
}

.engine-trigger:active {
  background: rgba(76,175,80,0.28);
}

#search-engine-icon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  object-fit: contain;
  flex-shrink: 0;
}

.engine-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}

.engine-arrow {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.6);
  transition: transform 0.22s ease;
  flex-shrink: 0;
  line-height: 1;
}

.search-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.25);
  flex-shrink: 0;
}

.search-box input[type="text"] {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0 4px;
  height: 42px;
  font-size: 1rem;
  color: #fff;
  min-width: 0;
  width: 0;
  font-family: inherit;
}
.search-box input[type="text"]::placeholder { color: rgba(255, 255, 255, 0.65); }

/* ===== 清空按钮 ===== */
.clear-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  transition: background 0.18s, color 0.18s, transform 0.12s;
  line-height: 1;
  padding: 0;
}
.clear-btn:hover {
  background: rgba(255,255,255,0.22);
  color: #fff;
}
.clear-btn:active { transform: scale(0.9); }

/* ===== 搜索提交按钮 ===== */
.search-submit-btn {
  background: var(--primary);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
  font-size: 1rem;
}
.search-submit-btn:active { transform: scale(0.93); background: #388E3C; }

/* ===== 引擎内联面板 ===== */
.engine-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  animation: panelIn 0.18s ease;
}
.engine-list::-webkit-scrollbar { display: none; }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.engine-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.22);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.93rem;
  font-weight: 600;
  transition: all 0.18s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}

.engine-btn img {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  object-fit: contain;
  flex-shrink: 0;
}

.engine-btn:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.25);
  color: #fff;
}

.engine-btn.active {
  background: rgba(76,175,80,0.18);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 6px rgba(76,175,80,0.2);
}

/* ===== 分区 ===== */
.section {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-section);
  padding: 1.3rem;
  margin-bottom: 2rem;
}

.section.section-hidden { display: none; }

.section-title {
  color: var(--primary);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1em;
  background: var(--primary);
  border-radius: 1px;
}

/* ===== 卡片网格 ===== */
.link-container {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: stretch;
}

/* ===== 卡片 ===== */
.card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  transition: background 0.25s, transform 0.25s, border-color 0.25s;
  position: relative;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  padding: 11px;
  gap: 5px;
  height: 100%;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.card img.favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
}

.card .title {
  font-weight: 600;
  font-size: 0.88rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.card .desc {
  font-size: 0.73rem;
  color: var(--text-dim);
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  flex: 1;
}

/* ===== Hover 弹出信息（桌面端） ===== */
@media (hover: hover) {
  .card:hover {
    background: rgba(255,255,255,0.18);
    transform: translateY(-4px);
    border-color: var(--primary);
  }

  .card .info-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    width: 200px;
    background: rgba(10, 10, 10, 0.92);
    border: 1px solid var(--primary);
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 0.74rem;
    color: #fff;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    z-index: 100;
    word-break: break-all;
    white-space: normal;
    max-width: calc(100vw - 24px);
  }

  .card:hover .info-popup {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ===== 触屏：长按弹出 tooltip ===== */
@media (hover: none) {
  .card:active {
    background: rgba(255,255,255,0.18);
    border-color: var(--primary);
  }

  .card .info-popup {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: min(320px, calc(100vw - 32px));
    background: rgba(10, 10, 10, 0.95);
    border: 2px solid var(--primary);
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    word-break: break-all;
    white-space: normal;
    transition: opacity 0.2s;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  }

  .card.touch-active .info-popup { opacity: 1; }
}

.card.hidden { display: none; }

/* ===== 响应式断点 ===== */
@media (max-width: 1200px) {
  .link-container { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .link-container { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .link-container { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem; }
  .card { padding: 9px 8px; }
  .card .desc { -webkit-line-clamp: 2; font-size: 0.7rem; }
}

@media (max-width: 480px) {
  .search-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 2px;
  }
  .search-tabs::-webkit-scrollbar { display: none; }
  .search-tab {
    flex-shrink: 0;
    padding: 6px 13px;
    font-size: 0.85rem;
  }
  .tab-icon { font-size: 0.9rem; }
  .tab-label { font-size: 0.85rem; }

  .engine-list {
    flex-wrap: wrap;
    overflow-x: unset;
    justify-content: center;
  }
  .engine-btn {
    padding: 4px 9px;
    font-size: 0.74rem;
    gap: 3px;
  }
  .engine-btn img {
    width: 12px;
    height: 12px;
  }

  .container { padding: 0.75rem; }
  .header-area { gap: 8px; margin-bottom: 1rem; }
  .header-icon { font-size: 1.3rem; }

  .search-box { padding: 4px 8px 4px 6px; gap: 4px; }
  /* 搜索框内触发器：比引擎气泡略小或相当 */
  .engine-trigger { padding: 3px 6px; gap: 4px; }
  .engine-name { font-size: 0.7rem; }
  #search-engine-icon { width: 13px; height: 13px; }
  .engine-arrow { font-size: 0.6rem; }
  .search-box input[type="text"] { font-size: 0.9rem; height: 38px; }
  .search-submit-btn { width: 34px; height: 34px; font-size: 0.9rem; }

  .section { padding: 0.9rem 0.75rem; border-radius: 14px; }
  .link-container { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }

  .card { padding: 8px 6px; border-radius: 10px; gap: 4px; }
  .card .title { font-size: 0.75rem; }
  .card img.favicon { width: 16px; height: 16px; }
  .card .desc { font-size: 0.67rem; }
}

@media (max-width: 360px) {
  .link-container { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; }
  .card { padding: 7px 5px; }
  .card .title { font-size: 0.7rem; }
  .search-tab { padding: 3px 8px; }
}

/* ===== 内外网切换按钮 ===== */
.net-toggle-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 999;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 0.85rem;
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.25s, border-color 0.25s;
  user-select: none;
}

.net-toggle-btn:hover { background: rgba(0, 0, 0, 0.6); }

.net-toggle-btn.intranet-active {
  background: rgba(210, 90, 20, 0.65);
  border-color: rgba(255, 150, 70, 0.5);
}

.net-toggle-btn.intranet-active:hover { background: rgba(210, 90, 20, 0.85); }
