.family-index {
  --family-surface: #f7f5ef;
  --family-surface-elevated: #fff;
  --family-ink: #171a21;
  --family-muted: #5d6470;
  --family-rule: #c9cbd0;
  --family-accent: #14388a;
  --family-focus: #005fcc;
  --family-current-bg: rgba(20, 56, 138, .09);
  --family-shadow: 0 24px 70px rgba(10, 13, 20, .22);
  --family-radius: 12px;
  --family-mobile-top: 72px;
  --family-desktop-top: 82px;
  position: relative;
  z-index: 1200;
  color: var(--family-ink);
  font-family: inherit;
}

.family-index > summary {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .8rem;
  border: 1px solid var(--family-rule);
  border-radius: var(--family-radius);
  background: var(--family-surface-elevated);
  color: var(--family-ink);
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: .78rem;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.family-index > summary::-webkit-details-marker { display: none; }
.family-index > summary::marker { content: ""; }
.family-index > summary:hover,
.family-index[open] > summary { border-color: var(--family-accent); color: var(--family-accent); }
.family-index > summary:focus-visible,
.family-index a:focus-visible {
  outline: 2px solid var(--family-focus);
  outline-offset: 3px;
}

.family-index__summary-mark {
  width: 1.1rem;
  height: 1.1rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  overflow: hidden;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}
.family-index__summary-mark::before { content: ""; background: #d21920; }
.family-index__summary-mark::after { content: ""; background: #14388a; }
.family-index__summary-count { color: var(--family-muted); font-size: .62rem; font-weight: 650; }
.family-index__summary-short { display: none; }
.family-index__chevron { width: 14px; height: 14px; transition: transform 180ms ease; }
.family-index[open] .family-index__chevron { transform: rotate(180deg); }

nav:has(.family-index[open]),
header:has(.family-index[open]) {
  z-index: 9999 !important;
  transform: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  perspective: none !important;
  contain: initial !important;
}

.family-index__panel {
  position: fixed;
  top: var(--family-desktop-top);
  right: max(16px, calc((100vw - 1200px) / 2));
  left: max(16px, calc((100vw - 1200px) / 2));
  width: auto;
  max-height: min(72vh, 680px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--family-rule);
  border-radius: var(--family-radius);
  background: var(--family-surface);
  color: var(--family-ink);
  box-shadow: var(--family-shadow);
  z-index: 1250;
  padding: 1rem;
  animation: family-index-enter 180ms ease-out both;
}

.family-index__intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: .25rem .25rem .9rem;
  border-bottom: 1px solid var(--family-rule);
}
.family-index__intro strong { display: block; font-size: 1rem; line-height: 1.25; }
.family-index__intro p { margin: .35rem 0 0; color: var(--family-muted); font-size: .75rem; line-height: 1.55; }
.family-index__home {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--family-accent);
  font-size: .75rem;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}
.family-index__home[aria-current="page"] { color: var(--family-muted); cursor: default; }

.family-menu {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
  justify-content: initial;
  gap: .75rem;
  width: auto;
  max-width: none;
  margin: 0;
  padding: .85rem 0 0;
}
.family-menu__group { min-width: 0; }
.family-menu__group h2 {
  margin: 0 0 .35rem;
  padding: 0 .45rem .45rem;
  border-bottom: 2px solid var(--family-accent);
  color: var(--family-muted);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.35;
  text-transform: uppercase;
}
.family-menu__group ul { margin: 0; padding: 0; list-style: none; }
.family-menu__group li + li { border-top: 1px solid var(--family-rule); }
.family-menu__item {
  min-height: 62px;
  display: grid;
  align-content: center;
  gap: .22rem;
  padding: .65rem .45rem;
  color: var(--family-ink);
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease;
}
a.family-menu__item:hover { background: var(--family-current-bg); color: var(--family-accent); }
.family-menu__item strong { font-size: .82rem; line-height: 1.25; }
.family-menu__item span { color: var(--family-muted); font-size: .68rem; line-height: 1.5; }
.family-menu__item small {
  width: max-content;
  margin-top: .12rem;
  padding: .16rem .35rem;
  border: 1px solid var(--family-rule);
  border-radius: 999px;
  color: var(--family-muted);
  font-size: .58rem;
  font-weight: 750;
  line-height: 1;
}
.family-menu__item.is-current { background: var(--family-current-bg); box-shadow: inset 3px 0 0 var(--family-accent); }
.family-menu__item.is-current strong::after { content: " · 当前"; color: var(--family-accent); font-size: .6rem; }
html[lang^="en"] .family-menu__item.is-current strong::after { content: " · Current"; }
html[lang^="ja"] .family-menu__item.is-current strong::after { content: " · 現在地"; }
.family-menu__item.is-disabled { opacity: .58; cursor: not-allowed; }

.family-index__locale { display: none; }
.family-index__locale[data-locale="zh-CN"] { display: block; }
html[lang^="en"] .family-index__locale { display: none; }
html[lang^="en"] .family-index__locale[data-locale="en"] { display: block; }
html[lang^="ja"] .family-index__locale { display: none; }
html[lang^="ja"] .family-index__locale[data-locale="ja"] { display: block; }
.family-index__trigger-locale { display: none; }
.family-index__trigger-locale[data-locale="zh-CN"] { display: inline; }
html[lang^="en"] .family-index__trigger-locale { display: none; }
html[lang^="en"] .family-index__trigger-locale[data-locale="en"] { display: inline; }
html[lang^="ja"] .family-index__trigger-locale { display: none; }
html[lang^="ja"] .family-index__trigger-locale[data-locale="ja"] { display: inline; }
.family-index__summary-short.family-index__trigger-locale { display: none; }

@keyframes family-index-enter {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1100px) {
  .family-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .family-index__summary-count { display: none; }
  .family-index__summary-label { display: none; }
  .family-index__summary-short { display: inline; }
  .family-index__summary-label.family-index__trigger-locale { display: none; }
  .family-index__summary-short.family-index__trigger-locale { display: none; }
  .family-index__summary-short.family-index__trigger-locale[data-locale="zh-CN"] { display: inline; }
  html[lang^="en"] .family-index__summary-short.family-index__trigger-locale { display: none; }
  html[lang^="en"] .family-index__summary-short.family-index__trigger-locale[data-locale="en"] { display: inline; }
  html[lang^="ja"] .family-index__summary-short.family-index__trigger-locale { display: none; }
  html[lang^="ja"] .family-index__summary-short.family-index__trigger-locale[data-locale="ja"] { display: inline; }
}

@media (max-width: 760px) {
  .family-index > summary { padding-inline: .65rem; }
  .family-index__summary-count { display: none; }
  .family-index__summary-label { display: none; }
  .family-index__summary-short { display: inline; }
  .family-index__summary-label.family-index__trigger-locale { display: none; }
  .family-index__summary-short.family-index__trigger-locale { display: none; }
  .family-index__summary-short.family-index__trigger-locale[data-locale="zh-CN"] { display: inline; }
  html[lang^="en"] .family-index__summary-short.family-index__trigger-locale { display: none; }
  html[lang^="en"] .family-index__summary-short.family-index__trigger-locale[data-locale="en"] { display: inline; }
  html[lang^="ja"] .family-index__summary-short.family-index__trigger-locale { display: none; }
  html[lang^="ja"] .family-index__summary-short.family-index__trigger-locale[data-locale="ja"] { display: inline; }
  .family-index__panel {
    position: fixed;
    inset: var(--family-mobile-top) 0 auto;
    width: auto;
    height: calc(100dvh - var(--family-mobile-top));
    max-height: calc(100dvh - var(--family-mobile-top));
    border-width: 1px 0 0;
    border-radius: 0;
    padding: 1rem max(1rem, env(safe-area-inset-right)) calc(1.2rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  }
  .family-index__intro { position: sticky; top: -1rem; z-index: 1; margin: -1rem -1rem 0; padding: 1rem; background: var(--family-surface); }
  .family-menu { grid-template-columns: 1fr; gap: 1rem; }
  .family-menu__item { min-height: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  .family-index__panel { animation: none; }
  .family-index__chevron,
  .family-index > summary,
  .family-menu__item { transition: none; }
}
