/* ============================================================================
   upon365 · 科研导航
   风格沿用 upon365 导航首页：清爽留白、圆角卡片、跟随系统深浅色
   ========================================================================== */

/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #f6f7f9;
  --bg-2: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --ink: #14171c;
  --ink-2: #2c3138;
  --ink-soft: #5a606a;
  --ink-faint: #8a9199;
  --line: rgba(16, 18, 24, .11);
  --line-soft: rgba(16, 18, 24, .06);
  --shadow: 0 1px 2px rgba(16, 18, 24, .05), 0 10px 26px rgba(16, 18, 24, .07);
  --shadow-lift: 0 2px 6px rgba(16, 18, 24, .08), 0 18px 40px rgba(16, 18, 24, .12);

  --radius: 16px;
  --radius-pill: 999px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur: .2s;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #141a21;
  --bg-2: #10151b;
  --surface: #1a212a;
  --surface-2: #202832;
  --ink: #f3f4f6;
  --ink-2: #dfe3e8;
  --ink-soft: #98a3b0;
  --ink-faint: #6d7783;
  --line: rgba(255, 255, 255, .12);
  --line-soft: rgba(255, 255, 255, .06);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px rgba(0, 0, 0, .3);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .34), 0 18px 40px rgba(0, 0, 0, .42);
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }

/* hidden 属性优先级最高，防止组件自身的 display 覆盖它 */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.wrap { width: min(1200px, 100% - 40px); margin: 0 auto; }

.skip {
  position: absolute; left: -9999px; top: 0;
  padding: 10px 16px; background: var(--surface); border-radius: 0 0 10px 0; z-index: 99;
}
.skip:focus { left: 0; }

:focus-visible { outline: 2px solid #4c8dff; outline-offset: 2px; }

/* ------------------------------------------------------------------ top */
.top {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.top__inner {
  width: min(1200px, 100% - 40px); margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 0;
}

.brand { display: inline-flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.brand__mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #0e9384, #1d6fd0);
  color: #fff; font-size: 15px;
}
.brand__txt {
  display: flex; flex-direction: column; line-height: 1.15;
  font-weight: 800; letter-spacing: -.01em; font-size: 15px;
}
.brand__txt small {
  font-size: 11px; font-weight: 600; color: var(--ink-soft); letter-spacing: .08em;
}

/* 搜索框（沿用导航首页的胶囊造型） */
.search {
  position: relative; flex: 1 1 auto; max-width: 460px; margin: 0 auto;
  display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search:focus-within {
  border-color: rgba(14, 147, 132, .5);
  box-shadow: var(--shadow), 0 0 0 4px rgba(14, 147, 132, .12);
}
.search__ico {
  width: 17px; height: 17px; margin-left: 14px; flex: 0 0 auto;
  fill: none; stroke: var(--ink-faint); stroke-width: 2; stroke-linecap: round;
}
.search input {
  flex: 1 1 auto; min-width: 0;
  padding: 10px 10px 10px 10px; border: 0; background: none;
  font: inherit; font-size: 14px; color: var(--ink);
  outline: none;
}
.search input::placeholder { color: var(--ink-faint); }
.search input::-webkit-search-cancel-button { display: none; }
.search__clear {
  flex: 0 0 auto; margin-right: 8px;
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--ink-soft);
  font-size: 14px; line-height: 1; cursor: pointer;
}
.search__clear:hover { background: var(--bg-2); color: var(--ink); }

.top__acts { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.tgl {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--ink-soft);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              background var(--dur) var(--ease);
}
.tgl:hover { color: var(--ink); border-color: var(--line); background: var(--surface-2); }
.tgl.is-on {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #0e9384, #118a7d);
}
[data-theme="dark"] .tgl.is-on { color: #06231f; }

.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--ink-2);
  font-size: 15px; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* 分类导航条 */
.cats {
  width: min(1200px, 100% - 40px); margin: 0 auto;
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 8px 0 10px;
  border-top: 1px solid var(--line-soft);
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto;
  padding: 6px 13px; border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--ink-soft);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              background var(--dur) var(--ease);
}
.cat:hover { color: var(--ink); background: var(--surface-2); }
.cat.is-active {
  color: hsl(var(--h, 200) 55% 38%);
  background: hsl(var(--h, 200) 70% 50% / .12);
  border-color: hsl(var(--h, 200) 60% 50% / .35);
}
[data-theme="dark"] .cat.is-active { color: hsl(var(--h, 200) 70% 72%); }
.cat.is-all { --h: 200; }

/* ----------------------------------------------------------------- hero */
.hero { position: relative; overflow: hidden; padding: 46px 0 30px; }
.hero__bg { position: absolute; inset: 0; pointer-events: none; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(58px); opacity: .5;
}
.orb--a { width: 420px; height: 420px; left: -80px; top: -160px; background: #7de3d4; }
.orb--b { width: 360px; height: 360px; right: 4%; top: -110px; background: #a9c7ff; }
.orb--c { width: 300px; height: 300px; left: 46%; top: -40px; background: #ffd9a0; opacity: .35; }
[data-theme="dark"] .orb { opacity: .22; }

.hero__inner { position: relative; }
.eyebrow {
  margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-faint);
}
.hero__title {
  margin: 0 0 10px; font-size: clamp(34px, 5vw, 50px); line-height: 1.08;
  letter-spacing: -.03em; font-weight: 800;
}
.hero__lead {
  margin: 0; max-width: 62ch; font-size: 15.5px; color: var(--ink-soft);
}
.hero__lead strong { color: var(--ink); font-weight: 650; }

.stats {
  display: flex; flex-wrap: wrap; gap: 8px 26px; margin: 22px 0 0; padding: 0; list-style: none;
}
.stats li { display: flex; align-items: baseline; gap: 6px; }
.stats b { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.stats span { font-size: 12.5px; color: var(--ink-soft); }

.recent {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 18px;
}
.recent__k { font-size: 12px; font-weight: 700; color: var(--ink-faint); letter-spacing: .06em; }
.recent__list { display: flex; flex-wrap: wrap; gap: 6px; }
.recent__item {
  padding: 4px 11px; border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: var(--surface); font-size: 12.5px; color: var(--ink-soft);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.recent__item:hover { color: var(--ink); background: var(--surface-2); }
.recent__clr {
  border: 0; background: none; color: var(--ink-faint);
  font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline;
}
.recent__clr:hover { color: var(--ink); }

/* --------------------------------------------------------------- groups */
.groups { padding: 18px 0 8px; }

.grp { padding: 6px 0 26px; scroll-margin-top: 130px; }

.grp__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 4px;
}
.grp__title {
  display: inline-flex; align-items: center; gap: 9px;
  margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.01em;
}
.grp__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: hsl(var(--h, 200) 62% 48%);
  box-shadow: 0 0 0 4px hsl(var(--h, 200) 62% 48% / .16);
}
.grp__en {
  font-size: 11.5px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint); font-style: normal;
}
.grp__count {
  flex: 0 0 auto;
  padding: 2px 10px; border-radius: var(--radius-pill);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  font-size: 12px; font-weight: 700; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.grp__note {
  margin: 0 0 14px; font-size: 13px; color: var(--ink-soft);
}

.sites {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
}

/* ---------------------------------------------------------------- cards */
.site {
  position: relative;
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
  color: var(--ink);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.site:hover, .site:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
  border-color: hsl(var(--h, 200) 55% 55% / .45);
}
.site.is-star { border-color: hsl(var(--h, 200) 55% 50% / .3); }

.site__ico {
  position: relative; flex: 0 0 auto;
  width: 30px; height: 30px;
  display: grid; place-items: center;
}
.site__fav {
  width: 18px; height: 18px; border-radius: 4px;
  image-rendering: auto;
}
.site__ini {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 9px;
  background: hsl(var(--h, 200) 62% 48% / .12);
  color: hsl(var(--h, 200) 55% 38%);
  font-size: 12px; font-weight: 800; letter-spacing: 0;
  opacity: 0;                       /* 默认藏在 favicon 后面，加载失败时才显示 */
  transition: opacity .15s var(--ease);
}
[data-theme="dark"] .site__ini { color: hsl(var(--h, 200) 68% 72%); }
.site__ico.no-fav .site__ini { opacity: 1; }
.site__ico.no-fav .site__fav { display: none; }

.site__txt { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.site__name {
  display: flex; align-items: center; gap: 5px;
  font-size: 14px; font-weight: 700; letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site__star { color: #f0b429; font-size: 11px; font-style: normal; }
.site__desc {
  font-size: 12.5px; color: var(--ink-soft); line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.site__host {
  margin-top: 2px;
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site__go {
  flex: 0 0 auto; margin-top: 1px;
  font-size: 13px; color: var(--ink-faint);
  opacity: 0; transform: translate(-3px, 3px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.site:hover .site__go, .site:focus-visible .site__go { opacity: .8; transform: none; }

/* ---------------------------------------------------------------- empty */
.empty { padding: 60px 0 90px; text-align: center; }
.empty__t { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.empty__d { margin: 0; font-size: 13.5px; color: var(--ink-soft); }

/* ----------------------------------------------------------------- foot */
.foot {
  margin-top: 20px; padding: 34px 0 40px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.foot__inner {
  display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.foot__brand { margin: 0 0 6px; font-weight: 800; font-size: 14.5px; }
.foot__note { margin: 0 0 6px; font-size: 12.5px; color: var(--ink-soft); }
.foot h4 {
  margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint);
}
.foot a { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
.foot a:hover { color: var(--ink); text-decoration: underline; }
.foot__note a { display: inline; color: var(--accent, #0e9384); }
.foot kbd {
  display: inline-block; padding: 1px 6px; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface-2); font-family: var(--mono); font-size: 11px;
}

/* ------------------------------------------------------------------ fab */
.fab {
  position: fixed; right: 20px; bottom: 22px; z-index: 40;
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--ink-2);
  box-shadow: var(--shadow-lift); font-size: 16px; cursor: pointer;
}
.fab:hover { background: var(--surface-2); }

/* ----------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .top__inner { flex-wrap: wrap; }
  .search { order: 3; max-width: none; width: 100%; margin: 4px 0 0; }
  .top__acts { margin-left: auto; }
}
@media (max-width: 560px) {
  .hero { padding-top: 34px; }
  .sites { grid-template-columns: 1fr; }
  .brand__txt small { display: none; }
  .brand__txt { font-size: 14px; }
  .top__inner { gap: 10px; }
  .top__acts { gap: 6px; }
  .top__acts .tgl { padding: 6px 9px; font-size: 11.5px; }
  /* 小屏空间有限：收起图标开关（默认已开），保留常用与主题 */
  #icoBtn { display: none; }
  .icon-btn { width: 31px; height: 31px; font-size: 14px; }
  .fab { right: 14px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .site, .cat, .tgl, .icon-btn { transition: none; }
}
