/* Public navigation site — self-contained styles (no admin CSS). */
:root {
  --nav-bg: #f4f6f3;
  --nav-surface: #ffffff;
  --nav-surface-soft: #f8faf8;
  --nav-text: #172033;
  --nav-muted: #667085;
  --nav-line: #dfe6e1;
  --nav-accent: #2764e7;
  --nav-accent-weak: #eaf1ff;
  --nav-radius: 12px;
  --nav-shadow: 0 1px 2px rgba(23, 32, 51, 0.05), 0 12px 30px rgba(23, 32, 51, 0.07);
  --nav-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --nav-bg: #0f141b;
  --nav-surface: #161d27;
  --nav-surface-soft: #1b2431;
  --nav-text: #e7edf4;
  --nav-muted: #8b98a6;
  --nav-line: #26313e;
  --nav-accent: #6ea8ff;
  --nav-accent-weak: #1c2b42;
  --nav-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 30px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body.nav-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  font-family: var(--nav-font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--nav-text);
  background: var(--nav-bg);
  background-image: radial-gradient(
      circle at 10% 0%,
      rgba(39, 100, 231, 0.055),
      transparent 34rem
    ),
    radial-gradient(
      circle at 92% 2%,
      rgba(11, 143, 102, 0.05),
      transparent 30rem
    );
  background-attachment: fixed;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.nav-skip {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  font-size: 13px;
  color: #fff;
  text-decoration: none;
  background: var(--nav-accent);
  border-radius: 8px;
  transition: top 140ms ease;
}

.nav-skip:focus {
  top: 12px;
}

/* ---------- Header ---------- */

.nav-header {
  position: sticky;
  top: 0;
  z-index: 30;
  width: 100%;
  background: var(--nav-bg);
  background: color-mix(in srgb, var(--nav-bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--nav-line);
}

.nav-header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  flex: 0 0 auto;
}

.nav-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, #2764e7, #0b8f66);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  flex: 0 0 auto;
}

.nav-brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.nav-brand-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-brand-copy small {
  margin-top: 2px;
  font-size: 12px;
  color: var(--nav-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 420px;
  margin-left: auto;
}

.nav-search input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 14px;
  font: inherit;
  font-size: 14px;
  color: var(--nav-text);
  background: var(--nav-surface);
  border: 1px solid var(--nav-line);
  border-radius: 999px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
  -webkit-appearance: none;
  appearance: none;
}

.nav-search input::placeholder {
  color: var(--nav-muted);
}

.nav-search input:focus {
  border-color: var(--nav-accent);
  box-shadow: 0 0 0 3px var(--nav-accent-weak);
}

.nav-search kbd {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  min-width: 20px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 11px;
  text-align: center;
  color: var(--nav-muted);
  background: var(--nav-surface-soft);
  border: 1px solid var(--nav-line);
  border-radius: 5px;
  pointer-events: none;
}

.nav-header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.nav-stat {
  font-size: 12px;
  color: var(--nav-muted);
  white-space: nowrap;
}

.nav-admin {
  display: inline-flex;
  align-items: center;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--nav-muted);
  text-decoration: none;
  border-radius: 6px;
  white-space: nowrap;
}

.nav-admin:hover {
  color: var(--nav-accent);
  background: var(--nav-surface-soft);
}

.nav-admin:focus-visible {
  outline: 2px solid var(--nav-accent);
  outline-offset: 2px;
}

.nav-theme {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  font-size: 16px;
  line-height: 1;
  color: var(--nav-text);
  background: var(--nav-surface);
  border: 1px solid var(--nav-line);
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.nav-theme:hover {
  border-color: var(--nav-accent);
}

/* ---------- Layout ---------- */

.nav-layout {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  align-items: start;
  gap: 30px;
  flex: 1 0 auto;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 56px;
}

.nav-layout-empty {
  grid-template-columns: minmax(0, 1fr);
}

.nav-sidebar {
  position: sticky;
  top: 82px;
  align-self: start;
  max-height: calc(100vh - 106px);
  padding: 4px 4px 16px 0;
  overflow: auto;
  scrollbar-width: thin;
}

.nav-sidebar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px 10px;
}

.nav-sidebar-title {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--nav-muted);
  text-transform: uppercase;
}

.nav-sidebar-total {
  font-size: 11px;
  color: var(--nav-muted);
  white-space: nowrap;
}

.nav-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-side-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--nav-text);
  text-decoration: none;
  border-radius: 8px;
  transition: background 120ms ease, color 120ms ease;
}

.nav-side-item:hover {
  background: var(--nav-surface-soft);
}

.nav-side-item.is-active {
  color: var(--nav-accent);
  background: var(--nav-accent-weak);
  font-weight: 600;
}

.nav-side-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot, var(--nav-accent));
}

.nav-side-star {
  display: none;
}

.nav-side-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-side-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--nav-muted);
}

.nav-side-item.is-active .nav-side-count {
  color: inherit;
}

.nav-sidebar-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding: 14px 10px 0;
  font-size: 12px;
  border-top: 1px solid var(--nav-line);
}

.nav-sidebar-foot a {
  color: var(--nav-muted);
  text-decoration: none;
}

.nav-sidebar-foot a:hover {
  color: var(--nav-accent);
}

.nav-main {
  min-width: 0;
}

.nav-main-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
}

/* ---------- Mobile category rail ---------- */

.nav-mobile-chips {
  display: none;
}

.nav-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 26px;
}

.nav-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--nav-text);
  text-decoration: none;
  background: var(--nav-surface);
  border: 1px solid var(--nav-line);
  border-radius: 999px;
  white-space: nowrap;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.nav-chip:hover,
.nav-chip.is-active {
  border-color: var(--nav-accent);
  background: var(--nav-accent-weak);
}

.nav-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot, var(--nav-accent));
}

.nav-chip-count {
  font-size: 11px;
  color: var(--nav-muted);
}

.nav-chip:hover .nav-chip-count,
.nav-chip.is-active .nav-chip-count {
  color: var(--nav-accent);
}

/* ---------- Directory ---------- */

.nav-featured,
.nav-group {
  margin-bottom: 32px;
  scroll-margin-top: 88px;
}

.nav-featured {
  padding-bottom: 6px;
}

.nav-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.nav-group-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.nav-group-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--nav-accent));
}

.nav-group-star {
  font-size: 11px;
  color: var(--nav-accent);
}

.nav-group-count {
  font-size: 12px;
  color: var(--nav-muted);
  white-space: nowrap;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(208px, 1fr));
  gap: 10px;
}

.nav-grid-featured {
  grid-template-columns: repeat(auto-fill, minmax(208px, 1fr));
}

.nav-site {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 58px;
  padding: 9px 11px;
  text-decoration: none;
  background: var(--nav-surface);
  border: 1px solid var(--nav-line);
  border-radius: var(--nav-radius);
  transition: transform 140ms ease, box-shadow 140ms ease,
    border-color 140ms ease;
}

.nav-site:hover {
  transform: translateY(-1px);
  border-color: var(--nav-accent);
  border-color: color-mix(in srgb, var(--nav-accent) 38%, var(--nav-line));
  box-shadow: var(--nav-shadow);
}

.nav-site:focus-visible {
  outline: 2px solid var(--nav-accent);
  outline-offset: 2px;
}

.nav-site-icon {
  position: relative;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--nav-surface-soft);
  background: color-mix(in srgb, var(--site-color) 14%, var(--nav-surface));
}

.nav-site-icon-letter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--site-color);
}

.nav-site-icon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--nav-surface);
  border-radius: 8px;
}

.nav-site-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.nav-site-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-site-badge {
  flex: 0 0 auto;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 500;
  line-height: 16px;
  color: var(--nav-accent);
  background: var(--nav-accent-weak);
  border-radius: 4px;
}

.nav-site-desc {
  margin-top: 1px;
  font-size: 12px;
  color: var(--nav-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Empty states ---------- */

.nav-empty,
.nav-empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--nav-muted);
  background: var(--nav-surface);
  border: 1px dashed var(--nav-line);
  border-radius: var(--nav-radius);
}

.nav-empty-state h2 {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--nav-text);
}

.nav-empty-state p {
  margin: 0 0 16px;
  font-size: 13px;
}

.nav-empty-link {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  font-size: 13px;
  color: #fff;
  text-decoration: none;
  background: var(--nav-accent);
  border-radius: 8px;
}

.nav-empty-link:hover {
  filter: brightness(1.05);
}

/* ---------- Footer ---------- */

.nav-footer {
  width: 100%;
  font-size: 12px;
  color: var(--nav-muted);
  border-top: 1px solid var(--nav-line);
}

.nav-footer-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 24px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.nav-footer-brand strong {
  font-size: 13px;
  color: var(--nav-text);
}

.nav-footer-brand p {
  margin: 4px 0 0;
}

.nav-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 16px;
}

.nav-footer-links a {
  color: var(--nav-muted);
  text-decoration: none;
}

.nav-footer-links a:hover {
  color: var(--nav-accent);
}

.nav-copyright {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  opacity: 0.75;
}

/* ---------- Back to top ---------- */

.nav-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 40px;
  height: 40px;
  font-size: 16px;
  color: var(--nav-text);
  background: var(--nav-surface);
  border: 1px solid var(--nav-line);
  border-radius: 50%;
  box-shadow: var(--nav-shadow);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
}

.nav-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ---------- Fallback ---------- */

.nav-fallback {
  max-width: 520px;
  margin: 18vh auto 0;
  padding: 0 20px;
  text-align: center;
}

.nav-fallback h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.nav-fallback p {
  margin: 6px 0;
  color: var(--nav-muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .nav-layout {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 16px;
  }

  .nav-sidebar {
    display: none;
  }

  .nav-mobile-chips {
    display: block;
    margin: 0 -20px 20px;
    padding: 0 20px;
  }

  .nav-mobile-chips .nav-chips {
    flex-wrap: nowrap;
    margin: 0;
    padding-bottom: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .nav-mobile-chips .nav-chips::-webkit-scrollbar {
    display: none;
  }

  .nav-mobile-chips .nav-chip {
    flex: 0 0 auto;
  }

  .nav-stat {
    display: none;
  }
}

@media (max-width: 760px) {
  .nav-header-inner {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
  }

  .nav-brand {
    flex: 1 1 auto;
  }

  .nav-search {
    order: 3;
    flex-basis: 100%;
    width: 100%;
    max-width: none;
    margin-left: 0;
  }

  .nav-header-meta {
    margin-left: auto;
  }

  .nav-layout {
    padding: 16px 14px 40px;
  }

  .nav-mobile-chips {
    margin: 0 -14px 18px;
    padding: 0 14px;
  }

  .nav-grid,
  .nav-grid-featured {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .nav-site-desc {
    display: none;
  }

  .nav-footer-inner {
    grid-template-columns: minmax(0, 1fr);
  }

  .nav-footer-links {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .nav-brand-copy small {
    display: none;
  }

  .nav-brand-title {
    font-size: 15px;
  }

  .nav-grid,
  .nav-grid-featured {
    grid-template-columns: 1fr;
  }

  .nav-site-desc {
    display: block;
  }

  .nav-group-head h2 {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
