
:host { display: block; }
*,*::before,*::after { box-sizing: border-box; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button,a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
svg { flex-shrink: 0; }

.site-header, .site-footer {
  /* 在影子内部阻断页面的继承排版；保留公开变量和宿主隐藏/禁用语义。 */
  all: initial;
  display: block;
  box-sizing: border-box;
  direction: ltr;
  unicode-bidi: normal;
  visibility: inherit;
  pointer-events: inherit;
  --ink: var(--site-ink, #26170f);
  --paper: var(--site-paper, #fff8ef);
  --muted: var(--site-muted, #766254);
  --line: var(--site-line, #ecdfd0);
  --accent: var(--site-accent, #c84918);
  --surface: var(--site-surface, #fffaf4);
  font-family: var(--site-font, "Inter", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif);
  font-weight: 400;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  line-height: normal;
  text-align: left;
}

.site-header {
  position: relative;
  z-index: 50;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  color-scheme: light;
  transition: background .35s ease, border-color .35s ease, color .35s ease;
}
.site-header[data-theme="dark"] {
  --ink: var(--site-ink, #f4f1ff);
  --paper: var(--site-paper, #090d24);
  --muted: var(--site-muted, #b0b5d2);
  --line: var(--site-line, #292d4e);
  --accent: var(--site-accent, #9bafff);
  --surface: var(--site-surface, #131830);
  color-scheme: dark;
}
.header-inner {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--site-layout-max, 2400px);
  height: 68px;
  padding: 0 var(--site-layout-gutter, clamp(28px, 4vw, 96px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(20px, 2.5vw, 48px);
}

.brand { display: inline-flex; align-items: center; gap: 10px; height: 44px; flex: 0 0 auto; color: inherit; }
.brand-wordmark {
  font-size: 19px;
  letter-spacing: -0.03em;
  line-height: 1;
  font-weight: 700;
  color: var(--ink);
}
.brand-wordmark > span { color: var(--accent); }

.primary-nav { display: flex; align-items: center; gap: clamp(16px, 1.8vw, 32px); }
.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  transition: color .2s ease;
}
.nav-link:hover { color: var(--ink); }
.nav-link.is-current,
.collection-trigger[aria-expanded="true"] { color: var(--accent); }

.nav-home, .collection-trigger, .explore-link { white-space: nowrap; }
.collection-heading { display: flex; align-items: center; gap: 3px; }
.collection-trigger { justify-content: center; gap: 7px; width: auto; }
.collection-trigger svg { transition: transform .2s ease; }
.collection-trigger svg.rotated { transform: rotate(180deg); }
.collection-nav { position: relative; }

/* 页面级主行动 */
.explore-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 20px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: transform .22s cubic-bezier(.2,.7,.25,1), box-shadow .3s ease, background .22s ease, border-color .22s ease;
}
.explore-link svg { transition: transform .28s cubic-bezier(.2,.7,.25,1); }
.explore-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--accent) 70%, transparent);
}
.explore-link:hover svg { transform: translate(2px, -2px); }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  margin-left: -10px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  color: var(--ink);
  transition: background .25s ease, border-color .25s ease, color .25s ease, box-shadow .25s ease;
}
.theme-toggle svg { transition: transform .4s cubic-bezier(.2,.7,.25,1); }
.theme-toggle:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  color: var(--accent);
  box-shadow: 0 0 24px -10px var(--accent);
}
.theme-toggle:hover svg { transform: rotate(18deg); }
.theme-toggle[aria-pressed="true"] { color: var(--accent); }

/* 下拉菜单 */
.collection-panel {
  box-sizing: border-box;
  position: absolute;
  top: calc(100% + 16px);
  right: 0;
  width: 296px;
  padding: 14px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 0 0 20px 20px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  color: var(--ink);
  box-shadow: 0 22px 48px -20px rgba(23, 20, 15, .28), 0 2px 6px rgba(23, 20, 15, .05);
  animation: slideDownFade .26s cubic-bezier(.2, .8, .25, 1);
}
@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.collection-panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 26px;
  width: 44px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
}
.collection-panel::after { content: ""; position: absolute; top: -18px; left: -1px; right: -1px; height: 18px; }
.collection-groups { display: grid; grid-template-columns: 1fr; gap: 26px; }
.group-title {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--muted);
}
.collection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 12px;
  margin: 0 -12px;
  border-radius: 10px;
  font-size: 14px;
  text-decoration: none;
  color: var(--ink);
  transition: background .18s ease, color .18s ease, padding-left .18s ease;
}
a.collection-item::after {
  content: "↗";
  font-size: 13px;
  color: var(--accent);
  opacity: 0;
  transform: translate(-4px, 4px);
  transition: opacity .18s ease, transform .18s ease;
}
a.collection-item:hover { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); padding-left: 16px; }
a.collection-item:hover::after { opacity: 1; transform: translate(0, 0); }
.collection-item-pending { gap: 14px; color: var(--muted); cursor: default; }
.collection-pending-label { min-width: 0; }
.collection-status { flex-shrink: 0; font-size: 11px; color: var(--muted); }

.site-header a:focus-visible,
.site-header button:focus-visible,
.collection-panel:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }

.mobile-toggle { display: none; }

@media (max-width: 700px) {
  .header-inner { height: auto; min-height: 62px; flex-wrap: wrap; gap: 0; }
  .brand-wordmark { font-size: 18px; }
  .mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
  }
  .mobile-toggle:hover { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
  .primary-nav { display: none; order: 3; width: 100%; padding: 6px 0 22px; gap: 0; align-items: stretch; }
  .primary-nav.is-open { display: flex; flex-direction: column; }
  .nav-link { min-height: 52px; font-size: 15px; color: var(--ink); }
  .primary-nav > .nav-link,
  .collection-heading { border-bottom: 1px solid var(--line); }
  .collection-heading > a { flex: 1; }
  .collection-trigger { width: 44px; }
  .explore-link { align-self: stretch; justify-content: space-between; min-height: 48px; margin-top: 16px; padding-inline: 22px; font-size: 14px; }
  .theme-toggle { margin: 14px 0 0; align-self: flex-end; }
  .collection-panel {
    position: static;
    width: 100%;
    padding: 16px 14px 14px;
    margin: 4px 0 10px;
    border: 0;
    border-radius: 0 0 16px 16px;
    box-shadow: none;
    animation: none;
  }
  .collection-panel::before, .collection-panel::after { display: none; }
  .collection-groups { gap: 16px; }
  .group-title { font-size: 12px; }
  .collection-item { min-height: 44px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* 基础 HTML 使用原生 details：没有 JavaScript 时工具入口仍可展开。 */
.collection-trigger { list-style:none; }
.collection-trigger::-webkit-details-marker { display:none; }
.collection-nav[open] > .collection-trigger { color:var(--accent); }
.collection-nav[open] > .collection-trigger svg { transform:rotate(180deg); }
.site-header summary:focus-visible { outline:2px solid var(--accent); outline-offset:4px; border-radius:8px; }
