:root {
  color-scheme: dark;
  --bg: #101412;
  --surface: #171c19;
  --surface-2: #1d231f;
  --surface-3: #242b26;
  --text: #f3f5f3;
  --text-2: #aeb8b1;
  --text-3: #778079;
  --line: #2b342e;
  --line-strong: #3a463e;
  --green: #7bc95b;
  --green-strong: #5fad42;
  --green-soft: rgba(123, 201, 91, 0.12);
  --cyan: #72c6d4;
  --amber: #e6b85c;
  --danger: #ef756b;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  --radius: 6px;
  --max-width: 1240px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6f2;
  --surface: #ffffff;
  --surface-2: #edf2ec;
  --surface-3: #e4ebe3;
  --text: #182019;
  --text-2: #526057;
  --text-3: #7b887f;
  --line: #d8e0d8;
  --line-strong: #c1ccc2;
  --green: #3e8c32;
  --green-strong: #307426;
  --green-soft: rgba(62, 140, 50, 0.1);
  --cyan: #277e90;
  --amber: #9a6c10;
  --danger: #bf4038;
  --shadow: 0 18px 48px rgba(25, 43, 29, 0.1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
  transition: background-color 180ms ease, color 180ms ease;
}

button, input { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 1000; top: 10px; left: 10px; transform: translateY(-160%); padding: 8px 12px; background: var(--green); color: #0b120c; border-radius: 4px; }
.skip-link:focus { transform: translateY(0); }

.topbar { position: sticky; top: 0; z-index: 100; height: 68px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(18px); }
.topbar-inner { width: min(calc(100% - 40px), var(--max-width)); height: 100%; margin: 0 auto; display: flex; align-items: center; gap: 36px; }
.brand { display: inline-flex; align-items: center; gap: 10px; flex: none; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface-2); box-shadow: inset 0 0 0 3px var(--surface); }
.brand-mark img { width: 24px; height: 24px; object-fit: contain; }
.brand-mark span { font-weight: 900; color: var(--green); }
.brand-copy { display: grid; line-height: 1.1; }
.brand-copy strong { font-size: 0.96rem; font-weight: 800; }
.brand-copy small { margin-top: 4px; color: var(--text-3); font-size: 0.65rem; }

.topnav { display: flex; align-self: stretch; align-items: center; gap: 26px; }
.topnav a { position: relative; display: grid; align-items: center; height: 100%; color: var(--text-2); font-size: 0.82rem; font-weight: 600; }
.topnav a:hover, .topnav a.active { color: var(--text); }
.topnav a.active::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--green); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-button, .mode-toggle { height: 36px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); cursor: pointer; transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease; }
.icon-button:hover, .mode-toggle:hover { border-color: var(--line-strong); background: var(--surface-2); }
.icon-button:focus-visible, .mode-toggle:focus-visible, .cat-btn:focus-visible, .site-card:focus-within { outline: 2px solid var(--green); outline-offset: 2px; }
.icon-button { width: 36px; display: grid; place-items: center; }
.mode-toggle { display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; color: var(--text-2); font-size: 0.76rem; font-weight: 600; }
.icon-button svg, .mode-toggle svg { width: 16px; height: 16px; stroke-width: 1.8; }
.theme-toggle .sun { display: none; }
[data-theme="light"] .theme-toggle .moon { display: none; }
[data-theme="light"] .theme-toggle .sun { display: block; }

.hero { border-bottom: 1px solid var(--line); background: linear-gradient(90deg, color-mix(in srgb, var(--green) 7%, transparent) 1px, transparent 1px), linear-gradient(color-mix(in srgb, var(--green) 7%, transparent) 1px, transparent 1px), var(--surface); background-size: 32px 32px; }
.hero-inner { width: min(calc(100% - 40px), var(--max-width)); min-height: 350px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr); align-items: center; gap: 72px; padding: 52px 0; }
.eyebrow, .section-kicker { margin: 0; color: var(--green); font-size: 0.68rem; font-weight: 800; }
.eyebrow { display: flex; align-items: center; gap: 9px; }
.eyebrow span { width: 18px; height: 2px; background: var(--green); }
.hero h1 { margin: 12px 0 10px; max-width: 760px; font-size: clamp(2.4rem, 6vw, 4.9rem); line-height: 1.04; font-weight: 850; }
.hero-description { max-width: 640px; margin: 0; color: var(--text-2); font-size: 1rem; }

.search-box { position: relative; width: min(100%, 640px); height: 52px; margin-top: 28px; display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--bg); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12); transition: border-color 160ms ease, box-shadow 160ms ease; }
.search-box:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.search-box > svg { width: 19px; height: 19px; margin-left: 16px; color: var(--text-3); flex: none; }
.search-box input { min-width: 0; flex: 1; height: 100%; border: 0; outline: 0; padding: 0 12px; background: transparent; color: var(--text); font-size: 0.9rem; }
.search-box input::placeholder { color: var(--text-3); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-box kbd { margin-right: 12px; padding: 2px 7px; border: 1px solid var(--line); border-bottom-color: var(--line-strong); border-radius: 4px; background: var(--surface-2); color: var(--text-3); font-family: inherit; font-size: 0.68rem; }
.search-clear { display: none; width: 34px; height: 34px; margin-right: 8px; border: 0; background: transparent; color: var(--text-3); cursor: pointer; }
.search-clear.visible { display: grid; place-items: center; }
.search-box:has(.search-clear.visible) kbd { display: none; }
.search-clear svg { width: 16px; height: 16px; }

.network-overview { min-width: 0; border-left: 1px solid var(--line-strong); padding-left: 32px; }
.overview-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--text-2); font-size: 0.72rem; font-weight: 700; }
.online-indicator { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-weight: 600; }
.online-indicator i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); margin: 22px 0 28px; }
.metrics div { border-right: 1px solid var(--line); padding: 0 18px; }
.metrics div:first-child { padding-left: 0; }
.metrics div:last-child { padding-right: 0; border-right: 0; }
.metrics dt { font-size: 1.45rem; font-weight: 800; }
.metrics dd { margin: 3px 0 0; color: var(--text-3); font-size: 0.67rem; }

.featured-sites { display: grid; gap: 6px; }
.featured-link { min-width: 0; display: grid; grid-template-columns: 34px minmax(0, 1fr) 16px; align-items: center; gap: 10px; padding: 9px; border: 1px solid transparent; border-radius: 5px; transition: background-color 160ms ease, border-color 160ms ease; }
.featured-link:hover { border-color: var(--line); background: var(--surface-2); }
.featured-link img, .featured-fallback { width: 34px; height: 34px; padding: 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); object-fit: contain; }
.featured-fallback { display: grid; place-items: center; color: var(--green); font-weight: 800; padding: 0; }
.featured-link span { min-width: 0; }
.featured-link strong, .featured-link small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.featured-link strong { font-size: 0.78rem; }
.featured-link small { margin-top: 2px; color: var(--text-3); font-size: 0.64rem; }
.featured-link > svg { width: 15px; height: 15px; color: var(--text-3); }

.directory { width: min(calc(100% - 40px), var(--max-width)); min-height: 520px; margin: 0 auto; padding: 52px 0 76px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 6px 0 0; font-size: 1.65rem; line-height: 1.2; }
.result-summary { margin: 0; color: var(--text-3); font-size: 0.78rem; }
.result-summary strong { color: var(--text); }
.filter-row { margin: 26px 0 22px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.category-tabs { display: flex; min-width: max-content; gap: 24px; }
.cat-btn { position: relative; height: 40px; padding: 0; border: 0; background: transparent; color: var(--text-3); cursor: pointer; font-size: 0.77rem; font-weight: 650; }
.cat-btn:hover { color: var(--text-2); }
.cat-btn.active { color: var(--text); }
.cat-btn.active::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--green); }
.cat-count { margin-left: 5px; color: var(--text-3); font-size: 0.65rem; font-variant-numeric: tabular-nums; }
.cat-btn.active .cat-count { color: var(--green); }

.site-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.site-card { position: relative; min-width: 0; min-height: 172px; display: flex; flex-direction: column; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease; animation: card-enter 320ms ease both; }
.site-card:hover { transform: translateY(-2px); border-color: var(--line-strong); background: var(--surface-2); box-shadow: var(--shadow); }
.site-card-head { display: flex; align-items: flex-start; gap: 12px; }
.site-logo { width: 42px; height: 42px; flex: none; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); }
.site-logo img { width: 28px; height: 28px; object-fit: contain; }
.site-logo .fallback { color: var(--green); font-size: 0.88rem; font-weight: 850; }
.site-card-title { min-width: 0; flex: 1; padding-top: 1px; }
.site-card-title h3 { margin: 0; font-size: 0.91rem; line-height: 1.35; }
.site-card-title h3 a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-card-title h3 a::after { content: ""; position: absolute; inset: 0; }
.site-category { display: inline-block; margin-top: 5px; color: var(--green); font-size: 0.63rem; font-weight: 650; }
.site-description { min-height: 42px; margin: 16px 0 14px; color: var(--text-2); display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 0.76rem; line-height: 1.65; }
.site-card-footer { position: relative; z-index: 1; margin-top: auto; display: flex; align-items: center; gap: 10px; }
.site-domain { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); font-size: 0.66rem; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.external-link { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; color: var(--text-3); background: var(--surface); transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease; }
.external-link:hover { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.external-link svg { width: 14px; height: 14px; }

.empty-state { padding: 70px 20px; text-align: center; }
.empty-state[hidden] { display: none; }
.empty-icon { width: 54px; height: 54px; margin: 0 auto 16px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text-3); }
.empty-icon svg { width: 23px; height: 23px; }
.empty-state h3 { margin: 0 0 6px; font-size: 1rem; }
.empty-state p { margin: 0 0 18px; color: var(--text-3); font-size: 0.8rem; }
.empty-state button { padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); cursor: pointer; font-size: 0.76rem; }
.empty-state button:hover { border-color: var(--green); color: var(--green); }
.load-error { grid-column: 1 / -1; padding: 50px; border: 1px solid var(--line); text-align: center; color: var(--danger); }

.footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { width: min(calc(100% - 40px), var(--max-width)); min-height: 110px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.footer-inner > div { display: grid; gap: 5px; }
.footer strong { font-size: 0.78rem; }
.footer span, .footer a { color: var(--text-3); font-size: 0.68rem; }
.footer a:hover { color: var(--green); }
.footer-links { text-align: right; }

@keyframes card-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

@media (max-width: 980px) {
  .hero-inner { grid-template-columns: 1fr; gap: 40px; }
  .network-overview { border-top: 1px solid var(--line-strong); border-left: 0; padding-top: 28px; padding-left: 0; }
  .featured-sites { grid-template-columns: repeat(3, 1fr); }
  .featured-link { grid-template-columns: 34px minmax(0, 1fr); }
  .featured-link > svg { display: none; }
  .site-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .topbar { height: 60px; }
  .topbar-inner, .hero-inner, .directory, .footer-inner { width: min(calc(100% - 28px), var(--max-width)); }
  .topnav { display: none; }
  .brand-copy small { display: none; }
  .mode-toggle { width: 36px; padding: 0; justify-content: center; }
  .mode-toggle span { display: none; }
  .hero-inner { min-height: 0; padding: 40px 0 34px; }
  .hero h1 { font-size: 2.55rem; }
  .hero-description { font-size: 0.88rem; }
  .search-box { height: 48px; margin-top: 22px; }
  .search-box kbd { display: none; }
  .network-overview { padding-top: 22px; }
  .metrics { margin: 18px 0 20px; }
  .featured-sites { grid-template-columns: 1fr; }
  .featured-link { padding: 7px 0; }
  .directory { padding: 38px 0 56px; }
  .section-heading { align-items: start; }
  .site-grid { grid-template-columns: 1fr; }
  .site-card { min-height: 158px; }
  .footer-inner { min-height: 140px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 18px; }
  .footer-links { text-align: left; }
}
