/* ============================================================
   YSearch 前台样式
   现代 · 专业 · 深/浅主题
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --primary: #6366f1;
  --primary-strong: #4f46e5;
  --primary-soft: rgba(99, 102, 241, .12);
  --accent: #8b5cf6;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --bg: #f6f7fb;
  --bg-card: #ffffff;
  --bg-hover: #f1f2f9;
  --text: #1f2333;
  --text-2: #5a6072;
  --text-3: #9aa0b4;
  --border: #e6e8f0;
  --border-strong: #d8dbe8;

  --mark-bg: #fef08a;
  --mark-text: #713f12;
  --shadow-sm: 0 1px 2px rgba(23, 25, 45, .06);
  --shadow-md: 0 6px 24px rgba(23, 25, 45, .10);
  --shadow-lg: 0 16px 48px rgba(23, 25, 45, .16);
  --radius: 14px;
  --radius-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}

[data-theme="dark"] {
  --primary: #818cf8;
  --primary-strong: #a5b4fc;
  --primary-soft: rgba(129, 140, 248, .16);
  --accent: #a78bfa;
  --grad: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);

  --bg: #0e1017;
  --bg-card: #171a24;
  --bg-hover: #1f2330;
  --text: #e6e8f0;
  --text-2: #a0a6ba;
  --text-3: #6b7185;
  --border: #262b3a;
  --border-strong: #333a4d;

  --mark-bg: #6d5a1f;
  --mark-text: #fde68a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .25s ease, color .25s ease;
}
a { color: var(--primary-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
code { font-family: var(--mono); font-size: .86em; background: var(--primary-soft); color: var(--primary-strong); padding: 1px 6px; border-radius: 5px; }

.page-wrap { flex: 1; }
::selection { background: var(--primary-soft); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

mark { background: var(--mark-bg); color: var(--mark-text); border-radius: 3px; padding: 0 1px; }

/* ---------- Logo ---------- */
.logo { display: inline-flex; flex-shrink: 0; }
.logo svg { display: block; }
.logo-lg { margin-bottom: 18px; filter: drop-shadow(0 8px 24px rgba(99, 102, 241, .35)); }
.logo-sm { transition: transform .2s ease; }
.logo-sm:hover { transform: scale(1.05); }

/* ---------- 首页 ---------- */
.home { max-width: 860px; margin: 0 auto; padding: 9vh 20px 40px; text-align: center; }
.home-hero { animation: rise .5s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.home-title {
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: -.5px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.home-tagline { color: var(--text-2); margin: 10px 0 30px; font-size: 15px; }

/* ---------- 搜索框 ---------- */
.search-form { position: relative; width: 100%; }
.search-form-lg { max-width: 640px; margin: 0 auto; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft), var(--shadow-md);
}
.search-icon { color: var(--text-3); flex-shrink: 0; }
.search-box input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  padding: 10px 8px;
  min-width: 0;
}
.search-box input::placeholder { color: var(--text-3); }
.clear-btn {
  border: none;
  background: var(--bg-hover);
  color: var(--text-2);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}
.clear-btn:hover { background: var(--border-strong); }
.search-btn {
  border: none;
  background: var(--grad);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 10px 24px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter .15s ease, transform .1s ease;
}
.search-btn:hover { filter: brightness(1.08); }
.search-btn:active { transform: scale(.97); }

/* 搜索建议 */
.suggest {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 50;
  text-align: left;
  animation: rise .18s ease both;
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text);
  font-size: 15px;
}
.suggest-item:hover, .suggest-item.active { background: var(--bg-hover); }
.suggest-item .s-icon { color: var(--text-3); flex-shrink: 0; font-size: 14px; }
.suggest-item .s-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-item .s-type { margin-left: auto; font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.suggest-footer {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  background: var(--bg-hover);
}

/* ---------- 首页快捷/公告/统计 ---------- */
.home-shortcuts { margin-top: 26px; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.shortcut-label { color: var(--text-3); font-size: 13px; }
.chip {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--primary); color: var(--primary-strong); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.chip-outline { border-style: dashed; }
.chip-outline:hover { border-color: var(--primary); }

.announcement {
  margin: 26px auto 0;
  max-width: 560px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 13px;
}
.announcement-badge { font-weight: 700; background: var(--grad); color: #fff; padding: 1px 8px; border-radius: 999px; font-size: 11px; }

.home-stats {
  margin-top: 56px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  animation: rise .5s .1s ease both;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-num {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.5px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-label { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

.home-footer-note { margin-top: 48px; font-size: 12.5px; color: var(--text-3); }

/* ---------- 结果页头部 ---------- */
.result-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.result-header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.result-header .search-form { max-width: 560px; }
.result-header .search-box { border-radius: 999px; padding-left: 14px; }
.result-header .search-btn { padding: 8px 20px; font-size: 14px; }
.header-links { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-2);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .18s ease;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary-strong); transform: rotate(12deg); }
[data-theme="light"] .i-moon { display: none; }
[data-theme="dark"] .i-sun { display: none; }
[data-theme="dark"] .i-moon { display: block; }

/* ---------- 结果主体 ---------- */
.results-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 20px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 36px;
  align-items: start;
}

.results-meta { font-size: 13.5px; color: var(--text-2); margin-bottom: 18px; padding: 10px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.results-meta strong { color: var(--text); }
.site-tag { background: var(--primary-soft); color: var(--primary-strong); padding: 1px 7px; border-radius: 5px; font-family: var(--mono); }
.site-clear { margin-left: 6px; font-size: 12px; }

/* 结果列表 */
.results-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.result-item {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease;
  animation: rise .3s ease both;
}
.result-item:hover { background: var(--bg-card); border-color: var(--border); box-shadow: var(--shadow-sm); }
.result-rank {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.result-item:nth-child(1) .result-rank, .result-item:nth-child(2) .result-rank, .result-item:nth-child(3) .result-rank {
  background: var(--grad);
  color: #fff;
}
.result-body { min-width: 0; flex: 1; }
.result-title {
  display: block;
  font-size: 17.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 2px;
}
.result-title:hover { color: var(--primary-strong); text-decoration: underline; text-underline-offset: 3px; }
.result-url { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.url-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.url-text { font-family: var(--mono); color: var(--text-2); }
.result-meta-sep { color: var(--border-strong); }
.result-snippet { font-size: 14px; color: var(--text-2); line-height: 1.65; word-break: break-word; }

/* 分页 */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 30px 0 8px; flex-wrap: wrap; }
.pagination-info { font-size: 12.5px; color: var(--text-3); margin-right: 10px; }
.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-2);
  font-size: 14px;
  transition: all .15s ease;
}
a.page-btn:hover { border-color: var(--primary); color: var(--primary-strong); text-decoration: none; transform: translateY(-1px); }
.page-btn.active { background: var(--grad); color: #fff; border-color: transparent; font-weight: 700; box-shadow: 0 4px 14px rgba(99, 102, 241, .35); }
.page-ellipsis { color: var(--text-3); padding: 0 2px; }

.per-page { text-align: center; font-size: 13px; color: var(--text-3); }
.per-page a { color: var(--text-2); padding: 2px 8px; border-radius: 6px; }
.per-page a:hover { color: var(--primary-strong); background: var(--primary-soft); text-decoration: none; }
.per-active { font-weight: 700; color: var(--primary-strong); padding: 2px 8px; }

/* 空状态 */
.empty-state { text-align: center; padding: 70px 20px; animation: rise .4s ease both; }
.empty-icon { font-size: 52px; margin-bottom: 14px; }
.empty-state h2 { font-size: 20px; margin-bottom: 8px; }
.empty-state p { color: var(--text-2); margin-bottom: 22px; font-size: 14px; }
.empty-chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- 侧边栏 ---------- */
.results-sidebar { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 84px; }
.side-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.side-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 12px; letter-spacing: .4px; }
.side-list { list-style: none; }
.side-list li { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; color: var(--text-2); border-bottom: 1px dashed var(--border); }
.side-list li:last-child { border-bottom: none; }
.side-list b { color: var(--text); font-variant-numeric: tabular-nums; }
.side-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.side-tips { list-style: none; font-size: 12.5px; color: var(--text-2); }
.side-tips li { padding: 4px 0; }
.side-tips code { display: inline-block; }
.side-card-muted { background: transparent; box-shadow: none; }

/* ---------- 页脚 ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-card); }
.footer-inner { max-width: 1120px; margin: 0 auto; padding: 16px 20px; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); }
.footer-sep { color: var(--border-strong); }
.footer-theme {
  width: auto;
  height: auto;
  border: none;
  background: none;
  font-size: 12.5px;
  color: var(--text-3);
  padding: 2px 8px;
  border-radius: 6px;
}
.footer-theme:hover { color: var(--primary-strong); background: var(--primary-soft); transform: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .results-main { grid-template-columns: 1fr; gap: 20px; }
  .results-sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
  .side-card { flex: 1 1 220px; }
}
@media (max-width: 640px) {
  .home { padding-top: 6vh; }
  .home-stats { grid-template-columns: repeat(2, 1fr); }
  .result-header-inner { flex-wrap: wrap; }
  .result-header .search-form { order: 3; flex-basis: 100%; }
  .header-links { margin-left: auto; }
  .result-title { font-size: 16px; }
  .search-btn { padding: 10px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
