/* =========================================================================
 * 九紫科研工具箱 · 样式表
 * 主题：紫（九紫）+ 火（离火）双色体系，浅/深色双模式
 * ========================================================================= */

:root {
  --brand: #7c3aed;
  --brand-2: #a855f7;
  --fire: #f97316;
  --fire-2: #fbbf24;
  --link: #4e6ef2;

  --bg: #f4f6fb;
  --bg-2: #eef1f9;
  --card: rgba(255, 255, 255, .92);
  --card-solid: #ffffff;
  --card-hover: #f3f0ff;
  --line: #e8ebf3;
  --text: #232a3d;
  --text-2: #6b7488;
  --text-3: #9aa2b5;
  --shadow: 0 8px 24px rgba(35, 42, 61, .07);
  --shadow-lg: 0 18px 50px rgba(35, 42, 61, .16);
  --radius: 14px;
  --hero-fade: #f4f6fb;
}

html[data-theme="dark"] {
  --bg: #0f1118;
  --bg-2: #151824;
  --card: rgba(30, 34, 48, .88);
  --card-solid: #1c2030;
  --card-hover: #262b3f;
  --line: #2b3146;
  --text: #e8ebf5;
  --text-2: #a3abc2;
  --text-3: #7b8399;
  --shadow: 0 8px 24px rgba(0, 0, 0, .38);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  --hero-fade: #0f1118;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
img { border: 0; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c3c9da; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #a6aec5; background-clip: content-box; }

/* ============================ 首屏背景 ============================ */
.hero {
  position: absolute;
  inset: 0 0 auto 0;
  height: 100vh;
  overflow: hidden;
  z-index: 0;
  background:
    radial-gradient(900px 520px at 12% 6%, rgba(168, 85, 247, .55), transparent 62%),
    radial-gradient(760px 460px at 88% 2%, rgba(249, 115, 22, .38), transparent 60%),
    radial-gradient(900px 700px at 50% 96%, rgba(78, 110, 242, .30), transparent 62%),
    linear-gradient(160deg, #2a1358 0%, #43207d 38%, #6d34a8 68%, #8b46b8 100%);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .055) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(120% 90% at 50% 20%, #000 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(120% 90% at 50% 20%, #000 30%, transparent 78%);
}

.hero .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: .5;
  animation: float 14s ease-in-out infinite;
}
.hero .orb.a { width: 220px; height: 220px; left: 8%;  top: 46%; background: radial-gradient(circle at 30% 30%, #fbbf24, rgba(251, 191, 36, 0)); }
.hero .orb.b { width: 300px; height: 300px; right: 6%; top: 30%; background: radial-gradient(circle at 40% 40%, #f472b6, rgba(244, 114, 182, 0)); animation-delay: -4s; }
.hero .orb.c { width: 160px; height: 160px; left: 46%; top: 12%; background: radial-gradient(circle at 50% 50%, #67e8f9, rgba(103, 232, 249, 0)); animation-delay: -8s; }

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

.hero-fade {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 200px;
  background: linear-gradient(rgba(255, 255, 255, 0), var(--hero-fade));
  pointer-events: none;
}

/* ============================ 顶部条 ============================ */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 26px;
}

.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; letter-spacing: .5px; }
.logo-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  font-size: 17px;
  background: linear-gradient(135deg, var(--fire), var(--brand-2));
  box-shadow: 0 8px 20px rgba(249, 115, 22, .38);
}
.logo-text { font-size: 16px; }
.logo-text small { display: block; font-size: 11px; font-weight: 400; opacity: .72; letter-spacing: 2px; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.ghost-btn {
  height: 34px;
  padding: 0 14px;
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 10px;
  color: #fff;
  font-size: 13px;
  background: rgba(255, 255, 255, .12);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: background .2s, transform .2s, border-color .2s;
}
.ghost-btn:hover { background: rgba(255, 255, 255, .24); transform: translateY(-1px); }

/* ============================ 主容器 ============================ */
.container {
  position: relative;
  z-index: 10;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.hero-inner {
  padding-top: 13vh;
  text-align: center;
  color: #fff;
}

.site-title {
  margin: 0;
  font-size: 44px;
  line-height: 1.18;
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 0 6px 30px rgba(0, 0, 0, .35);
}
.site-title em {
  font-style: normal;
  background: linear-gradient(120deg, #ffd76e, #ff9d4d 45%, #ff7ab8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.site-sub {
  margin: 14px 0 0;
  font-size: 15px;
  color: rgba(255, 255, 255, .85);
  letter-spacing: 1px;
}
.site-sub .dot { margin: 0 8px; opacity: .5; }

/* ============================ 搜索区 ============================ */
.search-wrap {
  position: relative;
  z-index: 40;
  max-width: 760px;
  margin: 34px auto 0;
}

.search-bar {
  position: relative;
  display: flex;
  align-items: stretch;
  height: 56px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 16px;
  box-shadow: 0 16px 44px rgba(22, 12, 54, .30);
  transition: box-shadow .25s;
}
.search-bar:focus-within { box-shadow: 0 18px 50px rgba(22, 12, 54, .42), 0 0 0 3px rgba(168, 85, 247, .28); }

.engine-btn {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px 0 16px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 16px 0 0 16px;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background .2s;
}
.engine-btn:hover { background: #f6f4ff; }
.engine-btn .eb-ico {
  width: 26px; height: 26px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
}
.engine-btn .chev { font-size: 10px; color: var(--text-3); transition: transform .25s; }
.engine-btn.open .chev { transform: rotate(180deg); }

#search-input {
  flex: 1;
  min-width: 0;
  padding: 0 16px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15.5px;
  color: var(--text);
}
#search-input::placeholder { color: #b3b9c9; }

.search-submit {
  flex: none;
  width: 96px;
  margin: 5px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2) 55%, #e879f9);
  box-shadow: 0 8px 20px rgba(124, 58, 237, .38);
  transition: filter .2s, transform .2s;
}
.search-submit:hover { filter: brightness(1.08); transform: translateY(-1px); }
.search-submit:active { transform: translateY(0); }

.search-tip {
  margin: 10px 4px 0;
  font-size: 12px;
  color: rgba(255, 255, 255, .68);
  text-align: left;
  letter-spacing: .3px;
}
.search-tip kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .14);
  font-family: inherit;
  font-size: 11px;
}

/* --------- 引擎面板 --------- */
.engine-panel {
  position: absolute;
  left: 0;
  top: 64px;
  width: 430px;
  max-width: 100%;
  max-height: 340px;
  overflow-y: auto;
  padding: 10px;
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(.98);
  transform-origin: top left;
  transition: opacity .2s, transform .2s, visibility .2s;
}
.engine-panel.show { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

.panel-head {
  display: flex; align-items: center;
  padding: 6px 8px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 1px;
}
.panel-head::before {
  content: "";
  width: 3px; height: 12px;
  margin-right: 8px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
}

.engine-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.engine-list li {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  border-radius: 11px;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: background .18s, color .18s, padding-left .18s;
}
.engine-list li:hover { background: var(--card-hover); color: var(--brand); padding-left: 13px; }
.engine-list li.on { background: linear-gradient(135deg, #f0ecff, #e8e2ff); color: var(--brand); font-weight: 600; }
.engine-list li.on::after {
  content: "";
  width: 16px; height: 16px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / 9px no-repeat;
}
.engine-list .e-ico {
  width: 24px; height: 24px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

/* --------- 站内联想 --------- */
.suggest {
  position: absolute;
  left: 0; right: 0;
  top: 64px;
  padding: 8px;
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: none;
}
.suggest.show { display: block; }
.suggest .sg-head { padding: 6px 10px; font-size: 12px; color: var(--text-3); }
.suggest .sg-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.suggest .sg-item:hover, .suggest .sg-item.active { background: var(--card-hover); }
.suggest .sg-item .sg-ico {
  width: 26px; height: 26px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.suggest .sg-item .sg-name { font-size: 14px; color: var(--text); }
.suggest .sg-item .sg-cat { margin-left: auto; font-size: 11px; color: var(--text-3); }
.suggest .sg-empty { padding: 14px 10px; font-size: 13px; color: var(--text-3); text-align: center; }

/* ============================ 热搜条 ============================ */
.hot-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  max-width: 1000px;
  margin: 28px auto 0;
}
.hot-label {
  flex: none;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: #fff;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ff5757, #ff8246);
  box-shadow: 0 6px 16px rgba(255, 88, 88, .38);
}
.hot-bar a {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 13px;
  font-size: 13px;
  color: #3b4356;
  background: rgba(255, 255, 255, .93);
  border-radius: 20px;
  transition: transform .2s, box-shadow .2s, color .2s;
}
.hot-bar a:hover { transform: translateY(-2px); color: var(--brand); box-shadow: 0 8px 20px rgba(0, 0, 0, .16); }
.hot-bar .hot-badge {
  padding: 1px 6px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ff5656, #ff8246);
}

/* ============================ 横幅卡 ============================ */
.banners {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 34px 0 6px;
}
.banner-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  min-height: 104px;
  border-radius: var(--radius);
  color: #fff;
  box-shadow: var(--shadow);
  transition: transform .28s cubic-bezier(.2, .8, .3, 1), box-shadow .28s;
}
.banner-card::after {
  content: "";
  position: absolute;
  right: -34px; bottom: -46px;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
}
.banner-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.banner-card .b-tag {
  display: inline-block;
  padding: 2px 9px;
  margin-bottom: 10px;
  font-size: 11px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .25);
}
.banner-card .b-title { font-size: 15.5px; font-weight: 700; }
.banner-card .b-desc { margin-top: 7px; font-size: 12.5px; opacity: .88; }

/* ============================ 分类区块 ============================ */
.section {
  margin-top: 22px;
  padding: 16px 18px 12px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  scroll-margin-top: 18px;
}
.section.dynamic { border-style: dashed; }

.sec-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.sec-ico {
  width: 30px; height: 30px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  font-size: 15px;
  color: #fff;
  box-shadow: 0 6px 14px rgba(35, 42, 61, .16);
}
.sec-name { font-size: 16px; font-weight: 700; letter-spacing: .5px; }
.sec-desc { font-size: 12px; color: var(--text-3); }
.sec-count {
  margin-left: auto;
  padding: 2px 10px;
  font-size: 11.5px;
  color: var(--text-2);
  border-radius: 20px;
  background: var(--bg-2);
}
html[data-theme="dark"] .sec-count { background: rgba(255, 255, 255, .06); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 4px;
  padding: 8px 0 4px;
}

.tile {
  position: relative;
  display: block;
  padding: 14px 6px 12px;
  border-radius: 12px;
  text-align: center;
  transition: background .22s, transform .22s;
}
.tile:hover { background: var(--card-hover); transform: translateY(-4px); }

.tile .ico {
  position: relative;
  width: 46px; height: 46px;
  margin: 0 auto 9px;
  display: grid; place-items: center;
  border-radius: 13px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  box-shadow: 0 7px 16px rgba(35, 42, 61, .16);
  transition: box-shadow .22s;
}
.tile:hover .ico { box-shadow: 0 10px 22px rgba(124, 58, 237, .30); }
.tile .ico .ico-txt {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.5px;
  line-height: 1;
}
.tile .ico img {
  position: absolute;
  inset: 5px;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.tile .name {
  display: block;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile .badge {
  position: absolute;
  top: 6px; left: 8px;
  padding: 1px 5px;
  border-radius: 6px;
  font-size: 10px;
  line-height: 1.5;
  color: #fff;
  transform: scale(.94);
}
.tile .badge.hot { background: #f56c6c; }
.tile .badge.new { background: #409eff; }
.tile .badge.rec { background: #e6a23c; }

.tile .fav {
  position: absolute;
  top: 5px; right: 6px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .2s, background .2s, color .2s;
}
.tile:hover .fav { opacity: 1; }
.tile .fav:hover { background: rgba(124, 58, 237, .12); color: var(--brand); }
.tile .fav.on { opacity: 1; color: #f59e0b; }

/* 站内搜索命中高亮 */
.tile.hit { animation: hitPulse 1.5s ease-out 2; }
@keyframes hitPulse {
  0%   { box-shadow: 0 0 0 0 rgba(124, 58, 237, .55); background: rgba(124, 58, 237, .12); }
  100% { box-shadow: 0 0 0 14px rgba(124, 58, 237, 0); background: transparent; }
}

.empty-tip { padding: 26px 10px; text-align: center; font-size: 13px; color: var(--text-3); }

/* ============================ 左侧分类抽屉 ============================ */
.drawer {
  position: fixed;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 91;
  max-height: 82vh;
  width: 0;
  opacity: 0;
  overflow: hidden;
  padding: 10px 0;
  border-radius: 16px;
  background: var(--card-solid);
  box-shadow: 0 10px 40px rgba(20, 14, 44, .28);
  transition: width .34s cubic-bezier(.4, 0, .2, 1), opacity .2s;
}
.drawer.open { width: 172px; opacity: 1; overflow-y: auto; }

.drawer-handle {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 74px;
  display: grid; place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0 10px 10px 0;
  color: #fff;
  font-size: 12px;
  letter-spacing: 2px;
  writing-mode: vertical-rl;
  cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--fire));
  box-shadow: 4px 6px 18px rgba(124, 58, 237, .35);
  z-index: 92;
}
.drawer.open + .drawer-handle { box-shadow: 4px 6px 22px rgba(124, 58, 237, .6); }

.drawer a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  font-size: 13.5px;
  color: var(--text-2);
  white-space: nowrap;
  border-left: 3px solid transparent;
  transition: background .18s, color .18s, border-color .18s;
}
.drawer a:hover { background: var(--card-hover); color: var(--brand); }
.drawer a.active { color: var(--brand); font-weight: 600; border-left-color: var(--brand); background: var(--card-hover); }
.drawer a .d-ico { font-size: 15px; width: 18px; text-align: center; }

/* ============================ 返回顶部 ============================ */
.to-top {
  position: fixed;
  right: 20px;
  bottom: 26px;
  z-index: 95;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 13px;
  color: #fff;
  font-size: 17px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 26px rgba(124, 58, 237, .38);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity .25s, transform .25s, visibility .25s;
}
.to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { transform: translateY(-3px); }

/* ============================ 页脚 ============================ */
.footer {
  margin-top: 40px;
  padding: 26px 10px 6px;
  text-align: center;
  font-size: 12.5px;
  line-height: 2;
  color: var(--text-3);
}
.footer strong { color: var(--text-2); font-weight: 600; }
.footer a { color: var(--brand); }

/* ============================ 响应式 ============================ */
@media (max-width: 1024px) {
  .banners { grid-template-columns: repeat(2, 1fr); }
  .engine-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .drawer, .drawer-handle { display: none; }
  .hero-inner { padding-top: 11vh; }
  .site-title { font-size: 30px; letter-spacing: 1px; }
  .site-sub { font-size: 13px; }
  .search-bar { height: 50px; border-radius: 14px; }
  .engine-btn { padding: 0 8px 0 10px; }
  .engine-btn .eb-name { display: none; }
  .search-submit { width: 64px; letter-spacing: 0; }
  .engine-panel { width: 100%; top: 58px; }
  .suggest { top: 58px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .tile { padding: 11px 4px 9px; }
  .tile .ico { width: 40px; height: 40px; }
  .tile .ico img { width: 30px; height: 30px; inset: 5px; }
  .tile .name { font-size: 12px; }
  .tile .fav { opacity: 1; }
  .hot-bar { justify-content: flex-start; }
  .topbar { padding: 12px 16px; }
  .logo-text small { display: none; }
  .search-tip { display: none; }
}
