/* =========================================================================
 * LoRA 图鉴 · 本地模型库
 * 视觉取向：阅读室里的黄铜与纸面。深色为默认，浅色为备选。
 * 零外部依赖：无 CDN、无网络字体、无模型封面图。
 * ========================================================================= */

[hidden] { display: none !important; }

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

:root {
  color-scheme: light;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
    "Source Han Sans SC", sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC",
    "STSong", "SimSun", "Iowan Old Style", Palatino, Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --bg: #f7f5f2;
  --bg-deep: #efebe6;
  --surface: #fcfbfa;
  --surface-2: #f3f0eb;
  --surface-3: #e8e3dc;
  --text: #1b1712;
  --text-soft: #3d362d;
  --muted: #6f665a;
  --border: #e2d7c4;
  --border-strong: #cfc1a9;

  --brand: #FF6900;
  --brand-2: #FF7D26;
  --brand-ink: #FF6900;
  --brand-soft: #fff0e6;
  --on-brand: #fff;
  /* 与主站首页卡片下载弹窗一致：绿色实心主按钮 */
  --download: #07c160;
  --download-strong: #059a4c;
  --gold: #b9894b;
  --ok: #0f766e;
  --ok-soft: #e5f3ef;
  --danger: #9f1239;

  --search-bg: #fcfbfa;
  --shadow: 0 18px 36px -28px rgba(48, 36, 20, 0.55);
  --shadow-soft: 0 10px 30px -24px rgba(48, 36, 20, 0.4);
  --card-face: linear-gradient(180deg, color-mix(in srgb, var(--surface) 72%, #fff), var(--surface) 16px);
  --card-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 72%, transparent),
    2px 3px 4px rgba(48, 36, 20, 0.08),
    4px 7px 12px rgba(48, 36, 20, 0.14);
  --card-shadow-hover:
    inset 0 1px 0 color-mix(in srgb, #fff 82%, transparent),
    4px 10px 16px rgba(48, 36, 20, 0.16),
    8px 22px 34px rgba(48, 36, 20, 0.24);

  --radius: 16px;
  --radius-sm: 10px;
  --page: 1220px;
  --bar-h: 64px;
  --cover-ink: #4e3f32;
  --cover-shade: #261e18;
  --mark-bg: #f0d7a4;
  --mark-text: #3f2a10;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #121110;
  --bg-deep: #0c0b0a;
  --surface: #1b1917;
  --surface-2: #23211e;
  --surface-3: #2c2926;
  --text: #f6f1e7;
  --text-soft: #ded5c7;
  --muted: #b2a696;
  --border: #332c24;
  --border-strong: #4a4135;

  --brand: #FF6900;
  --brand-2: #FF7D26;
  --brand-ink: #FF6900;
  --brand-soft: #3d2414;
  --on-brand: #fff;
  --gold: #e0b878;
  --ok: #8fd0c4;
  --ok-soft: #16332e;
  --danger: #e7a8b2;

  --search-bg: #24211e;
  --shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.75);
  --shadow-soft: 0 12px 34px -26px rgba(0, 0, 0, 0.8);
  --card-face: linear-gradient(180deg, color-mix(in srgb, #3e372f 70%, #f3e6cf), #3e372f 16px);
  --card-shadow:
    inset 0 1px 0 rgba(255, 244, 220, 0.14),
    2px 3px 4px rgba(0, 0, 0, 0.55),
    4px 7px 12px rgba(0, 0, 0, 0.62);
  --card-shadow-hover:
    inset 0 1px 0 rgba(255, 244, 220, 0.16),
    4px 10px 16px rgba(0, 0, 0, 0.62),
    8px 22px 34px rgba(0, 0, 0, 0.78);

  --cover-ink: #6d6152;
  --cover-shade: #191410;
  --mark-bg: #6e5424;
  --mark-text: #f4e8d2;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 560px at 10% -12%, color-mix(in srgb, var(--brand) 11%, transparent), transparent 62%),
    radial-gradient(900px 520px at 96% -6%, color-mix(in srgb, var(--gold) 9%, transparent), transparent 58%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg { display: block; max-width: 100%; }

a {
  color: var(--brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

button { font: inherit; color: inherit; }

code,
kbd { font-family: var(--font-mono); }

::selection {
  background: color-mix(in srgb, var(--brand) 34%, transparent);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 72%, transparent);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 0 0 10px 10px;
  background: var(--brand);
  color: var(--on-brand);
  text-decoration: none;
  transition: top 0.18s ease;
}

.skip-link:focus { top: 0; }

#grid,
#stats-main {
  scroll-margin-top: calc(var(--bar-h) + 14px);
}

#grid:focus,
#stats-main:focus { outline: none; }

/* ---------------------------------------------------------------- topbar -- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--bar-h);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 22px;
  width: 100%;
  max-width: var(--page);
  height: 100%;
  margin: 0 auto;
  padding: 0 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 1.06rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.nav-link {
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: color 0.18s ease, background 0.18s ease;
}

.nav-link:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface-3) 55%, transparent);
}

.nav-link.is-active {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}

.header-tools { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.theme-toggle-icon { font-size: 1rem; line-height: 1; }

/* ------------------------------------------------------------------ hero -- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 34px 0 14px;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0, color-mix(in srgb, var(--brand) 7%, transparent) 50%, transparent 100%);
  mask-image: linear-gradient(180deg, black, transparent 78%);
  -webkit-mask-image: linear-gradient(180deg, black, transparent 78%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 28px;
  text-align: center;
}


.hero-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(2.15rem, 5.2vw, 3.45rem);
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: 0.01em;
}

.hero-title em {
  color: var(--brand);
  font-style: normal;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hero-break { display: none; }



/* ---------------------------------------------------------------- search -- */

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 720px;
  margin: 26px auto 0;
  padding: 7px 10px 7px 17px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--search-bg);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 55%, transparent),
    0 10px 30px -22px rgba(48, 36, 20, 0.5);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search:focus-within {
  border-color: color-mix(in srgb, var(--brand) 62%, var(--border-strong));
  outline: 2px solid color-mix(in srgb, var(--brand) 52%, transparent);
  outline-offset: 2px;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent),
    0 12px 34px -24px rgba(48, 36, 20, 0.55);
}

.search-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--muted);
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
}

.search-input::placeholder { color: color-mix(in srgb, var(--muted) 76%, transparent); }

.search-input::-webkit-search-cancel-button { display: none; }

.kbd {
  flex: 0 0 auto;
  min-width: 22px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
}

.search-clear {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.search-clear:hover { background: var(--surface-3); color: var(--text); }

/* ------------------------------------------------------------- layout -- */

.layout {
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 28px;
}

.library-page .layout { padding-bottom: 30px; }

/* ---------------------------------------------------------------- filters -- */

.filters {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 16px 20px;
  border: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-soft);
}

.filter-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  min-height: 30px;
}

.filter-row + .filter-row { border-top: 1px dashed color-mix(in srgb, var(--border) 66%, transparent); padding-top: 8px; }

.filter-label {
  padding-top: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  white-space: nowrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 5px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 0.81rem;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.chip.is-active {
  border-color: transparent;
  background: var(--brand);
  color: var(--on-brand);
}

.chip.is-active .chip-count { color: color-mix(in srgb, var(--on-brand) 72%, transparent); }

.chip-count {
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.chip.is-zero { opacity: 0.42; }
.chip.is-zero:hover { opacity: 0.6; }

.filter-row-sort {
  display: flex;
  align-items: center;
  gap: 14px;
}

.filter-row-sort .filter-label { padding-top: 0; }

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.segmented button {
  padding: 4px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.79rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.segmented button:hover { color: var(--text); }

.segmented button.is-active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(48, 36, 20, 0.16);
  font-weight: 600;
}

.filter-reset { margin-left: auto; }

/* ------------------------------------------------------------------ buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.3;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border-strong));
  background: var(--surface-2);
  color: var(--text);
  transform: translateY(-1px);
}

.btn.primary {
  border-color: transparent;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 88%, #f3e0c2), var(--brand));
  color: var(--on-brand);
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 16px -12px rgba(72, 44, 16, 0.8), inset 0 1px 0 rgba(255, 250, 240, 0.32);
}

.btn.primary:hover {
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 78%, #f7e8ce), var(--brand-2));
  color: var(--on-brand);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* 与首页卡片下载弹窗一致：主按钮实心，次按钮描边透明 */
.btn.copy {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-soft);
  font-weight: 600;
}

.btn.copy:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-ink);
}

/* ---------------------------------------------------------------- toolbar -- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 26px 0 12px;
}

.count {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.count strong { color: var(--text); font-weight: 650; }

.toolbar-actions { display: flex; align-items: center; gap: 8px; }

.active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 14px;
}

.active-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 6px 4px 11px;
  border: 1px solid color-mix(in srgb, var(--brand) 32%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 9%, transparent);
  color: var(--text-soft);
  font-size: 0.76rem;
}

.active-chip button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  color: var(--brand);
  font-size: 0.62rem;
  cursor: pointer;
}

.active-chip button:hover { background: var(--brand); color: var(--on-brand); }

.active-clear {
  padding: 4px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.74rem;
  cursor: pointer;
}

.active-clear:hover { color: var(--text); border-color: var(--brand); }

/* ------------------------------------------------------------------- grid -- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 12px;
  align-content: start;
}

/* ------------------------------------------------------------------- card -- */

.card {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  min-height: 126px;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: 12px;
  background: var(--card-face);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

@media (hover: hover) {
  .card:hover {
    z-index: 1;
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--brand) 72%, #6b4520);
    box-shadow:
      inset 0 0 0 1px color-mix(in srgb, var(--brand) 48%, transparent),
      var(--card-shadow-hover);
  }
}

.card:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 70%, transparent);
  outline-offset: 2px;
}

.card-spine {
  position: relative;
  grid-column: 1;
  grid-row: 1 / -1;
  display: grid;
  place-items: center;
  color: #faf3e5;
  background:
    linear-gradient(
      90deg,
      rgba(255, 246, 230, 0.38) 0%,
      rgba(255, 246, 230, 0.08) 13%,
      transparent 30%,
      transparent 66%,
      rgba(0, 0, 0, 0.2) 86%,
      rgba(0, 0, 0, 0.46) 100%
    ),
    linear-gradient(180deg, rgba(255, 246, 230, 0.16), transparent 26%),
    linear-gradient(
      168deg,
      color-mix(in srgb, var(--c1, var(--cover-ink)) 32%, var(--cover-ink)),
      color-mix(in srgb, var(--c2, var(--cover-shade)) 18%, var(--cover-shade))
    );
  box-shadow:
    inset 2px 0 3px rgba(255, 246, 230, 0.26),
    inset -7px 0 9px rgba(0, 0, 0, 0.34);
}

.card-spine::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 1px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(255, 248, 236, 0.6) 8%,
    rgba(255, 248, 236, 0.38) 92%,
    transparent
  );
}

.card-spine::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.05) 64%, rgba(255, 248, 236, 0.12));
}

.card-spine-text {
  position: absolute;
  z-index: 1;
  top: 8px;
  bottom: 8px;
  left: 0;
  right: 0;
  width: fit-content;
  max-width: calc(100% - 10px);
  margin: 0 auto;
  overflow: hidden;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
  overflow-wrap: anywhere;
}

.card-main {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
  padding: 11px 14px;
}

.card-title {
  margin: 0;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 0.96rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: 0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  transition: color 0.15s ease;
}

.card:hover .card-title { color: var(--text); }

.card-sub {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.card-author {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-sub-sep { color: color-mix(in srgb, var(--muted) 55%, transparent); }

.card-file {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: color-mix(in srgb, var(--muted) 82%, transparent);
  font-family: var(--font-mono);
  font-size: 0.64rem;
}

.card-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.tag-size {
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 0.68rem;
  line-height: 1.4;
  white-space: nowrap;
}

.tag-style {
  border-color: #d8d4ce;
  background: #eceae6;
  color: #5c5854;
}

html[data-theme="dark"] .tag-style {
  border-color: #3a3734;
  background: #2c2a28;
  color: #c8c3bc;
}

.card-source {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  color: var(--muted);
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.source-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.source-dot.src-civitai { background: #c8913f; }
.source-dot.src-huggingface { background: #d8b25a; }
.source-dot.src-local { background: color-mix(in srgb, var(--muted) 65%, transparent); }

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: auto 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.card-size { letter-spacing: 0.01em; }

.card-downloads {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}

.card-downloads svg {
  width: 11px;
  height: 11px;
  opacity: 0.72;
}

.card-keywords {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 0;
  max-height: 78px;
  overflow: hidden;
}

.kw {
  max-width: 100%;
  overflow: visible;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid #d8d4ce;
  background: #eceae6;
  color: #5c5854;
  font-size: 0.64rem;
  line-height: 1.5;
}

html[data-theme="dark"] .kw:not(.kw-more) {
  border-color: #3a3734;
  background: #2c2a28;
  color: #c8c3bc;
}

.kw-more {
  background: transparent;
  color: var(--muted);
  padding: 1px 3px;
}

/* --------------------------------------------------- loading / empty / more -- */

.loading,
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 280px;
  padding: 48px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 6%, var(--surface)), var(--surface-2));
  color: var(--text-soft);
  text-align: center;
}

.loading { font-family: var(--font-serif); letter-spacing: 0.06em; }

.loading-spine,
.empty-spine {
  width: 44px;
  height: 60px;
  border-radius: 2px 7px 7px 2px;
  background:
    linear-gradient(90deg, rgba(255, 244, 220, 0.22), transparent 18%),
    linear-gradient(165deg, var(--cover-ink), var(--cover-shade));
  box-shadow:
    inset 5px 0 0 color-mix(in srgb, var(--brand) 70%, #1a120c),
    inset -8px 0 12px rgba(0, 0, 0, 0.28);
}

.loading-spine { animation: spine-breathe 1.8s ease-in-out infinite; }

@keyframes spine-breathe {
  0%, 100% { opacity: 0.45; transform: translateY(1px); }
  50% { opacity: 1; transform: translateY(0); }
}

.empty-title {
  margin: 4px 0 0;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text);
}

.empty-hint { margin: 0 0 6px; color: var(--muted); font-size: 0.85rem; }

@media (max-width: 720px) {
  .content:has(> .empty:not([hidden])) > .toolbar {
    padding-bottom: 4px;
  }
  .empty {
    justify-content: flex-start;
    min-height: 0;
    gap: 4px;
    padding: 0 16px 12px;
  }
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 24px 0 6px;
}

.load-more { min-width: 168px; }

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

.to-top {
  position: fixed;
  right: 22px;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text-soft);
  font-size: 1rem;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.to-top:hover {
  border-color: var(--brand);
  color: var(--brand);
  transform: translateY(-2px);
}

/* ------------------------------------------------------------------ toast -- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  max-width: min(92vw, 420px);
  padding: 10px 18px;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--border-strong));
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  color: var(--text);
  font-size: 0.82rem;
  box-shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.55);
  transform: translate(-50%, 8px);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.toast.is-error {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border-strong));
}

/* ---------------------------------------------------------------- footer -- */

.site-footer {
  margin-top: 34px;
  border-top: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  background: color-mix(in srgb, var(--bg-deep) 42%, transparent);
}

.footer-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: 34px 28px 40px;
}

.footer-brand {
  margin: 0 0 8px;
  color: var(--text-soft);
  font-family: var(--font-serif);
  font-size: 0.98rem;
  letter-spacing: 0.06em;
}

.footer-notice {
  max-width: 700px;
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.75;
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.footer-meta a { color: var(--brand); }

.footer-dot { opacity: 0.5; }

/* ------------------------------------------------------------------ modal -- */

.model-dialog {
  /* 去掉左侧封面后收窄，避免右侧内容被拉得太散 */
  width: min(660px, calc(100vw - 32px));
  max-width: 660px;
  max-height: calc(100vh - 48px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--text);
  overflow: visible;
}

.model-dialog::backdrop {
  background: rgba(12, 9, 6, 0.62);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.dialog-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  box-shadow:
    0 40px 90px -30px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 color-mix(in srgb, #fff 38%, transparent);
  max-height: calc(100vh - 48px);
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 26px 30px 26px;
  overflow-y: auto;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--muted);
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.dialog-close:hover { background: var(--surface-2); color: var(--text); }

.dialog-title {
  margin: 0;
  padding-right: 34px; /* 给右上角关闭按钮留位 */
  font-family: var(--font-serif);
  font-size: clamp(1.3rem, 2.4vw, 1.65rem);
  font-weight: 650;
  line-height: 1.32;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.dialog-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 2px 0 0;
}

.meta-cell {
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid color-mix(in srgb, var(--border) 84%, transparent);
  border-radius: 10px;
  background: var(--surface-2);
}

.meta-cell dt {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
}

.meta-cell dd {
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-section { display: flex; flex-direction: column; gap: 6px; }
/* flex 容器会覆盖 UA 的 [hidden]，需显式隐藏无触发词的整块 */
.dialog-section[hidden] { display: none; }

.dialog-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.dialog-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.dialog-keywords .kw {
  max-width: none;
  font-size: 0.7rem;
  padding: 2px 8px;
}

.dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

/* 下载行完全对齐主站首页卡片弹窗 .dl-link：来源名 + 提取码在左，
   打开下载页 / 复制链接两个按钮靠右。 */
.dialog-actions .dl-link {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.dialog-actions .dl-link[hidden] { display: none; }

.dialog-actions .dl-link-info {
  display: flex;
  flex-flow: row nowrap;
  align-items: baseline;
  gap: 8px 12px;
  min-width: 0;
  flex: 1 1 auto;
}
.dialog-actions .dl-link-name {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.dialog-actions .dl-link-code {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dialog-actions .dl-link-code[hidden] { display: none; }
.dialog-actions .dl-link-actions {
  display: flex;
  flex-flow: row nowrap;
  flex: 0 0 auto;
  gap: 6px;
  margin-left: auto;
  width: auto;
}

@media (max-width: 600px) {
  .dialog-actions .dl-link-name { font-size: 11px; }
  .dialog-actions .dl-link-code { font-size: 10.5px; }
  .dialog-actions .dl-link-actions { gap: 4px; margin-left: 0; }
  .dialog-actions .dl-link-actions .btn {
    height: 28px;
    min-height: 28px;
    padding: 0 6px;
    font-size: 11px;
  }
}
@media (max-width: 360px) {
  .dialog-actions .dl-link { flex-wrap: wrap; align-items: stretch; }
  .dialog-actions .dl-link-info {
    flex: 1 1 100%;
    justify-content: space-between;
    width: 100%;
  }
}

/* 完全对齐首页卡片下载弹窗 .dl-link-actions .btn：
   绿色实心主按钮 + 描边次按钮，32px 等高、12px 字号、10px 圆角。 */
.dialog-actions .btn {
  flex: 0 0 auto;
  height: 32px;
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.dialog-actions .btn.primary {
  border-color: transparent;
  background: var(--download);
  color: #fff;
  letter-spacing: 0;
}

.dialog-actions .btn.primary:hover {
  background: var(--download-strong);
  color: #fff;
}

.dialog-actions .btn.copy {
  border-color: var(--border-strong);
  background: transparent;
  color: var(--text-soft);
}

.dialog-actions .btn.copy:hover {
  border-color: var(--download);
  background: transparent;
  color: var(--brand-ink);
}

.dialog-status {
  margin: -4px 0 0;
  color: var(--ok);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
}

.dialog-status.is-error { color: var(--danger); }

/* --------------------------------------------------------------- noscript -- */

.noscript {
  max-width: 760px;
  margin: 20px auto;
  padding: 16px 20px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.86rem;
  text-align: center;
}

/* -------------------------------------------------------------- responsive -- */

@media (max-width: 820px) {
  .topbar-inner { padding: 0 18px; gap: 12px; }
  .brand-sub { display: none; }
  .layout { padding-left: 18px; padding-right: 18px; }
  .hero { padding: 28px 0 10px; }
  .hero-inner { padding: 0 18px; }
  .filters { padding: 14px 16px; }
  .filter-row { grid-template-columns: 1fr; gap: 6px; }
  .filter-label { padding-top: 0; }
  .filter-row-sort { flex-wrap: wrap; }
  .filter-row + .filter-row { padding-top: 10px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .dialog-shell { max-height: calc(100vh - 32px); }
  .dialog-body { padding: 18px 20px 20px; gap: 12px; }
  /* 3 格 meta 固定一行；窄屏略收内边距与字号，避免文字被 ellipsis 截断 */
  .dialog-meta { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .dialog-meta .meta-cell { padding: 7px 8px; }
  .dialog-meta .meta-cell dt { font-size: 0.62rem; }
  .dialog-meta .meta-cell dd { font-size: 0.76rem; }
  .footer-inner { padding: 26px 18px 32px; }
}

@media (max-width: 600px) {
  .topbar-inner { gap: 8px; }
  .brand-name { font-size: 0.98rem; }
  .nav-link { padding: 6px 9px; font-size: 0.78rem; }
  .hero-title { font-size: clamp(1.85rem, 8.4vw, 2.5rem); }
  .hero-break { display: block; }
  .search { padding-left: 13px; }
  .search-input { font-size: 0.9rem; }
  .kbd { display: none; }
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .card { min-height: 126px; }
  .filter-row-sort { gap: 8px; }
  .filter-reset { margin-left: 0; }
  .toolbar { flex-wrap: wrap; gap: 8px; margin-top: 20px; }
  .dialog-actions .btn { flex: 1 1 auto; }
  .toast { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .card:hover { transform: none; }
}

/* ------------------------------------------------------------- final touches -- */

html.dialog-open,
html.dialog-open body { overflow: hidden; }

.card-author { flex: 0 1 auto; max-width: 46%; }

.count-total { color: var(--muted); }

.card-sub { min-height: 1.35em; }

@media (max-width: 600px) {
  .card-author { max-width: 38%; }
  .theme-toggle { width: 40px; height: 40px; }
  .chip { padding: 6px 12px; }
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 2px 2px 6px;
    margin: -2px -2px -6px;
  }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; padding: 7px 13px; }
  .filter-row[data-dimension] { position: relative; }
  .filter-row[data-dimension]::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(90deg, transparent, var(--surface));
    pointer-events: none;
  }
}

/* =========================================================================
 * 与主站首页一致的顶栏（从 ebook-vault-demo 的首页头部复刻）
 * ========================================================================= */

:root { --card: #f5efe4; }
html[data-theme="dark"] { --card: #3e372f; }

.topbar {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 40;
  height: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  min-height: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 0 0;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-theme="dark"] .topbar {
  background: color-mix(in srgb, #1c1a18 92%, transparent);
  backdrop-filter: saturate(1.08) blur(14px);
  -webkit-backdrop-filter: saturate(1.08) blur(14px);
  border-bottom-color: color-mix(in srgb, #5c5348 72%, transparent);
}

.topbar-inner {
  display: flex;
  flex: 1 1 auto;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  height: 100%;
  max-width: 1180px;
  min-width: 0;
  margin: 0 auto;
  padding: 0 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #3a332c;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-decoration: none;
}

html[data-theme="dark"] .brand { color: var(--text); }

.brand-text { min-width: 0; overflow: hidden; white-space: nowrap; }

.brand-name,
.brand-sub {
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
}

.brand-sub::before { content: " · "; }

.brand-mark {
  display: block;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  object-fit: contain;
}

.header-nav {
  --tool-h: 36px;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  white-space: nowrap;
}

.header-home,
.header-papers {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: var(--tool-h, 36px);
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.header-home:hover,
.header-home:focus-visible,
.header-papers:hover,
.header-papers:focus-visible {
  background: var(--surface-2);
  color: var(--brand-ink);
}

.header-home:focus-visible,
.header-papers:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

html[data-theme="dark"] .header-home:hover,
html[data-theme="dark"] .header-home:focus-visible,
html[data-theme="dark"] .header-papers:hover,
html[data-theme="dark"] .header-papers:focus-visible {
  background: color-mix(in srgb, var(--card) 78%, #1a1511);
  color: var(--text);
}

.header-home[aria-current="page"],
.header-papers[aria-current="page"],
.header-help[aria-current="page"] {
  position: relative;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: #FF6900;
  font-weight: 700;
}
.header-home[aria-current="page"]::after,
.header-papers[aria-current="page"]::after,
.header-help[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: #FF6900;
  pointer-events: none;
}
.header-home[aria-current="page"]:hover,
.header-papers[aria-current="page"]:hover,
.header-help[aria-current="page"]:hover,
html[data-theme="dark"] .header-home[aria-current="page"],
html[data-theme="dark"] .header-home[aria-current="page"]:hover,
html[data-theme="dark"] .header-papers[aria-current="page"],
html[data-theme="dark"] .header-papers[aria-current="page"]:hover,
html[data-theme="dark"] .header-help[aria-current="page"],
html[data-theme="dark"] .header-help[aria-current="page"]:hover {
  border-color: transparent;
  background: transparent;
  color: #FF6900;
}

@media (min-width: 721px) {
  .topbar-inner > .header-nav,
  .topbar-inner > .header-tools {
    align-self: stretch;
    height: auto;
  }
  .header-nav > a[aria-current="page"],
  .header-tools > a.header-github-hot[aria-current="page"],
  .header-tools > a.header-help[aria-current="page"] {
    align-self: stretch;
    height: auto;
  }
}

.header-github-hot {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: var(--tool-h, 36px);
  height: var(--tool-h, 36px);
  border: 1px solid transparent;
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
}

.header-github-hot:hover,
.header-github-hot:focus-visible {
  background: var(--surface-2);
  color: var(--brand-ink);
}

.header-github-hot:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.header-github-hot svg { display: block; width: 22px; height: 22px; }

.header-news {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: var(--tool-h, 36px);
  height: var(--tool-h, 36px);
  border: 1px solid transparent;
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
}
.header-news:hover,
.header-news:focus-visible { background: var(--surface-2); }
.header-news:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
html[data-theme="dark"] .header-news:hover,
html[data-theme="dark"] .header-news:focus-visible {
  background: color-mix(in srgb, var(--card) 78%, #1a1511);
}
.header-news .nav-fire,
.header-news .nav-fire-still {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
  pointer-events: none;
}
.header-news .nav-fire-still { display: none; }
@media (prefers-reduced-motion: reduce) {
  .header-news .nav-fire { display: none; }
  .header-news .nav-fire-still { display: block; }
}

html[data-theme="dark"] .header-github-hot:hover,
html[data-theme="dark"] .header-github-hot:focus-visible {
  background: color-mix(in srgb, var(--card) 78%, #1a1511);
  color: var(--text);
}

.header-tools {
  --tool-h: 36px;
  display: flex;
  flex: 0 0 auto;
  flex-shrink: 0;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-left: 0;
  white-space: nowrap;
}

.lang-switch {
  display: inline-flex;
  flex: 0 0 auto;
  flex-shrink: 0;
  flex-wrap: nowrap;
  align-items: stretch;
  align-self: center;
  box-sizing: border-box;
  height: var(--tool-h, 36px);
  margin-left: 0;
  padding: 2px;
  border: 1px solid color-mix(in srgb, var(--brand) 46%, var(--border-strong));
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  white-space: nowrap;
}

.lang-btn {
  appearance: none;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  height: 100%;
  min-height: 0;
  padding: 0 10px;
  border-radius: 999px;
  cursor: pointer;
}

.lang-btn:hover:not([aria-pressed="true"]) { color: var(--brand-ink); }

#lang-toggle {
  padding: 0 12px;
  color: var(--text);
  font-weight: 700;
}

#lang-toggle:hover,
#lang-toggle:focus-visible {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

html[data-theme="dark"] #lang-toggle:hover,
html[data-theme="dark"] #lang-toggle:focus-visible {
  background: color-mix(in srgb, var(--card) 78%, #1a1511);
  color: var(--text);
}

.theme-toggle {
  position: relative;
  flex: 0 0 auto;
  z-index: 2;
  box-sizing: border-box;
  width: var(--tool-h, 36px);
  height: var(--tool-h, 36px);
  display: grid;
  place-items: center;
  border: 1px solid #463e34;
  border-radius: 999px;
  background: #14110e;
  color: #f6f1e7;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: #d4b483;
  color: #f3e6cf;
}

html[data-theme="dark"] .theme-toggle {
  border-color: #d3c6b0;
  background: #f3eee4;
  color: #1c1814;
}

html[data-theme="dark"] .theme-toggle:hover {
  border-color: #8a5a2b;
  color: #6b4520;
}

@media (max-width: 720px) {
  body.library-page .topbar {
    height: auto;
    min-height: 0;
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    padding-bottom: 8px;
  }

  body.library-page .topbar-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas:
      ". brand actions"
      "nav nav nav";
    align-items: center;
    column-gap: 10px;
    row-gap: 8px;
    height: auto;
    padding: 0 16px;
  }

  body.library-page .topbar-inner .brand {
    grid-area: brand;
    justify-self: center;
    justify-content: center;
    text-align: center;
    font-size: 17px;
  }

  body.library-page .topbar-inner .header-nav {
    grid-area: nav;
    justify-content: center;
    margin-left: 0;
    gap: 6px;
  }

  body.library-page .topbar-inner .header-tools {
    grid-area: actions;
    justify-self: end;
    margin-left: 0;
  }

  body.library-page .brand-sub { display: none; }
}

@media (max-width: 600px) {
  .header-home,
  .header-papers { padding: 0 5px; font-size: 12px; }
  .theme-toggle { width: 36px; height: 36px; }
}


/* =========================================================================
 * 吸顶搜索：滚动时固定在主站顶栏下方
 * ========================================================================= */

.search-well {
  position: sticky;
  top: var(--header-h, var(--bar-h));
  z-index: 35;
  width: 100%;
  margin: 0;
  padding: 10px 28px 16px;
  background: var(--bg);
  box-shadow: 0 1px 0 var(--border);
}

.search-well .search {
  flex: none;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

@media (max-width: 820px) {
  .search-well { padding: 8px 18px 12px; }
}

@media (max-width: 600px) {
  .search-well { padding: 8px 16px 12px; }
}

/* 吸顶搜索会覆盖列表顶部，给锚点跳转留出空间。 */
#grid {
  scroll-margin-top: calc(var(--header-h, var(--bar-h)) + 108px);
}

/* =========================================================================
 * 筛选区：顶部说明 + 单列时折叠为弹窗
 * ========================================================================= */

.filter-lead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px;
}

.filter-lead-text {
  margin: 0;
  color: var(--text-soft);
  font-family: var(--font-serif);
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.filter-lead-text strong {
  color: var(--brand);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.filter-open { display: none; margin-left: auto; }

.filter-open-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
  .filters { padding: 12px 16px; }
  .filter-lead { margin: 0; }
  .filter-body { display: none; }
  .filter-open { display: inline-flex; }
  .filter-dialog-body .filter-body { display: block; }
}

.filter-dialog {
  width: min(560px, calc(100vw - 24px));
  max-width: 560px;
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

.filter-dialog::backdrop {
  background: rgba(12, 9, 6, 0.62);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.filter-dialog-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  padding: 20px 20px 14px;
}

.filter-dialog-title {
  margin: 0 0 4px;
  padding-right: 36px;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.filter-dialog .dialog-close { top: 12px; right: 12px; z-index: 2; }

.filter-dialog-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 4px -4px 0;
  padding: 0 4px 4px;
}

.filter-dialog-body .filter-body { display: block; }

.filter-dialog-body .filter-row {
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px 0;
}

.filter-dialog-body .filter-row + .filter-row {
  border-top: 1px dashed color-mix(in srgb, var(--border) 66%, transparent);
  padding-top: 10px;
}

.filter-dialog-body .filter-row:first-child { padding-top: 0; }

.filter-dialog-body .filter-label { padding-top: 0; }

.filter-dialog-body .chips {
  flex-wrap: wrap;
  overflow: visible;
  margin: 0;
  padding: 0;
}

.filter-dialog-body .chip { padding: 7px 12px; }

.filter-dialog-body .filter-row[data-dimension]::after { display: none; }

.filter-dialog-body .filter-reset { margin-left: auto; }

.filter-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* =========================================================================
 * 搜索框：与主站首页完全一致的视觉规格
 * ========================================================================= */

.search-well { padding: 16px 28px 12px; }

.search-well .search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: 0;
  width: auto;
  min-width: 0;
  max-width: 720px;
  margin: 0 auto;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--brand) 46%, #d4ccc2);
  border-radius: 14px;
  background: #fcfbfa;
  box-shadow:
    0 1px 0 color-mix(in srgb, #fff 50%, transparent),
    0 4px 10px -6px rgba(48, 36, 20, 0.32);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

html[data-theme="dark"] .search-well .search {
  border-color: #3d3833;
  background: #24211e;
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 220, 0.14),
    2px 3px 4px rgba(0, 0, 0, 0.55),
    4px 7px 12px rgba(0, 0, 0, 0.62);
}

.search-well .search:focus-within {
  outline: none;
  border-color: var(--brand);
  box-shadow:
    0 0 0 3px var(--brand),
    var(--shadow);
}

html[data-theme="dark"] .search-well .search:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 55%, transparent);
}

.search-well .search-icon {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin-left: 18px;
  color: var(--muted);
}

.search-well .search:focus-within .search-icon { color: var(--brand); }

.search-well .search-input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.search-well .search-input::placeholder {
  color: var(--placeholder, var(--muted));
  opacity: 1;
}

.search-well .search-input::-webkit-search-cancel-button {
  display: block;
  cursor: pointer;
}

/* 首页没有自定义清空按钮，使用搜索框原生清除按钮 */
.search-well .search-clear { display: none !important; }

.search-well .kbd {
  flex: 0 0 auto;
  min-width: 0;
  margin-right: 14px;
  padding: 2px 8px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

html[data-theme="dark"] .search-well .kbd {
  border-color: var(--card-border, #5c5348);
  background: #322c25;
}

.search-well .portal-ticker,
.search-well .search-row {
  width: 100%;
  max-width: calc(var(--page) - 56px);
  margin-left: auto;
  margin-right: auto;
}
.search-well .portal-ticker { margin-bottom: 10px; }
.search-well .search-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.search-well .search-row .search {
  flex: 1 1 auto;
  width: auto;
  max-width: none;
  margin: 0;
}
.search-submit {
  flex: 0 0 auto;
  height: 52px;
  min-width: 108px;
  padding: 0 26px;
  border: 0;
  border-radius: 14px;
  background: #FF6900;
  color: #fff;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}
.search-submit:hover { background: #FF7D26; color: #fff; }

@media (max-width: 820px) {
  .search-well { padding: 16px 18px 10px; }
  .search-well .portal-ticker,
  .search-well .search-row { max-width: none; }
}

/* =========================================================================
 * 页脚：与主站首页完全一致的固定底栏
 * ========================================================================= */

.site-footer {
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 10px 24px max(16px, env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  font-size: 12.5px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 28px -18px rgba(48, 36, 20, 0.55);
}

.site-footer .footer-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0;
}

.site-footer p { margin: 0; }
.site-footer p + p { margin-top: 0.55em; }

.footer-notice {
  max-width: none;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.footer-notice a,
.footer-notice a:visited,
.footer-notice a:hover {
  color: #0052D9;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.library-page .layout {
  padding-bottom: calc(var(--footer-stack, 96px) + 18px);
}

.to-top {
  bottom: calc(var(--footer-stack, 96px) + 16px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 820px) {
  .site-footer { padding-left: 16px; padding-right: 16px; }
}

/* 空标题时不占位 */
.hero-title:empty{display:none}

/* 标题为空时整个 hero 区块不占位（减少顶部留白） */
.hero:has(.hero-title:empty){display:none}

/* 卡片下载按钮（与首页一致的绿色按钮风格） */
.card-actions{display:flex;margin-top:2px}
.btn.download{
  display:inline-flex;align-items:center;justify-content:center;
  height:30px;padding:0 16px;border:0;border-radius:8px;cursor:pointer;
  background:#07c160;color:#fff;font-size:0.78rem;font-weight:700;line-height:1;
  font-family:inherit;white-space:nowrap;
}
.btn.download:hover{background:#059a4c}

/* 卡片下载按钮：完全对齐首页卡片样式（胶囊、28px、#07C160、整行宽度） */
.card .card-actions{display:flex;margin-top:auto;padding:8px 0 0}
.card .card-actions .btn.download{
  flex:1 1 auto;width:100%;height:28px;min-height:28px;padding:0 10px;
  font-size:12px;font-weight:650;letter-spacing:.04em;line-height:1;
  border:1px solid #07C160;border-radius:999px;background:#07C160;color:#fff;
  display:inline-flex;align-items:center;justify-content:center;
}
.card .card-actions .btn.download:hover{border-color:#06ad56;background:#06ad56;color:#fff}

/* 语言切换按钮：明暗两种主题下都保证文字可见、不溢出 */
.lang-switch{
  align-items:center;
  overflow:hidden;
  background:var(--surface-2);
  border:1px solid var(--border-strong);
}
.lang-btn{
  color:var(--text);
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
#lang-toggle{color:var(--text)!important}
html[data-theme="light"] #lang-toggle{color:#1c1814!important}
html[data-theme="dark"] #lang-toggle{color:#f6f1e7!important}

/* 极窄屏（≤360px）：3 格 meta 依旧固定一行，再收尺寸避免文字被省略号截断 */
@media (max-width: 360px) {
  .dialog-meta { gap: 4px; }
  .dialog-meta .meta-cell { padding: 6px 6px; }
  .dialog-meta .meta-cell dt { font-size: 0.6rem; }
  .dialog-meta .meta-cell dd { font-size: 0.7rem; }
}

/* ==================================================================
   深色弹窗对齐主站首页卡片下载弹窗（.dl-modal）
   首页深色弹窗是暖色 --card 面板 + --card-border 描边，行内下载块更深；
   这里把 LoRA 详情弹窗统一成同一套观感（亮色不变）。
   ================================================================== */
html[data-theme="dark"] {
  --card: #3e372f;
  --card-border: #5c5348;
}

/* 面板：亮色 = 首页同款 surface；深色 = 首页同款暖色 card + shadow */
html[data-theme="dark"] .dialog-shell {
  background: var(--card);
  border-color: var(--card-border);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 color-mix(in srgb, #fff 8%, transparent);
}

/* 尺寸/圆角/内边距对齐首页 .dl-modal */
.model-dialog { width: min(560px, calc(100vw - 32px)); max-width: 560px; }
.dialog-shell { border-radius: var(--radius); }
.dialog-body { padding: 26px 24px 22px; gap: 12px; }
.dialog-title { font-size: 20px; line-height: 1.35; letter-spacing: 0; }
.dialog-meta { gap: 8px; }
.dialog-actions { gap: 10px; }

/* 关闭按钮对齐首页 .dl-close：无边框圆形，深色下悬停用深色底 */
.dialog-close {
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  font-size: 20px;
}
html[data-theme="dark"] .dialog-close { color: var(--muted); }
html[data-theme="dark"] .dialog-close:hover {
  background: color-mix(in srgb, var(--card) 58%, #fff 10%);
  color: var(--text);
}

/* 深色下 meta 小格与下载行：面板上压一层更深的 surface-2，与首页一致 */
html[data-theme="dark"] .dialog-meta .meta-cell {
  border-color: color-mix(in srgb, var(--card-border) 62%, transparent);
  background: var(--surface-2);
}
html[data-theme="dark"] .dialog-actions .dl-link {
  border-color: color-mix(in srgb, var(--card-border) 55%, transparent);
  background: var(--surface-2);
}
html[data-theme="dark"] .dialog-keywords .kw {
  border-color: color-mix(in srgb, var(--card-border) 55%, transparent);
}

@media (max-width: 720px) {
  .dialog-body { padding: 18px 20px 20px; gap: 12px; }
}

/* 卡片上的本站点击次数（参考首页 .card-clicks） */
.card-clicks {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  line-height: 1.3;
}
.card-clicks[hidden] { display: none; }

/* “加载更多”：与软件列表页保持同一套样式 */
.load-more-wrap { padding: 18px 0 8px; }
.btn.primary.load-more,
.btn.load-more {
  min-width: 0;
  display: inline-flex;
  padding: 11px 32px;
  border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
  border-radius: var(--radius-sm, 10px);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: .02em;
  box-shadow: none;
  transform: none;
}
.btn.primary.load-more:hover,
.btn.load-more:hover {
  border-color: var(--brand);
  background: var(--surface-3);
  color: var(--text);
}

/* GitHub 入口：桌面显示在语言切换左侧；窄屏跟随导航放第二行 */
.header-github-hot--nav { display: none; }
@media (max-width: 720px) {
  .header-tools .header-github-hot { display: none; }
  .header-nav .header-github-hot--nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 8px;
  }
}

/* 帮助入口 */
.header-help { display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 10px; border-radius: 999px; color: inherit; font-size: 13px; text-decoration: none; }
.header-help:hover, .header-help:focus-visible { background: var(--surface-2); color: var(--brand-ink); }
.header-help--nav { display: none; }
@media (max-width: 720px) {
  .header-tools .header-help--desk { display: none; }
  .header-nav .header-help--nav { display: inline-flex; }
}

/* 窄屏导航：可横向滑动并居中当前项 */
@media (max-width: 720px) {
  .header-nav {
    flex-wrap: nowrap;
    justify-content: safe center;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .header-nav::-webkit-scrollbar { display: none; }
  .header-home,
  .header-papers { padding: 0 8px; font-size: 13px; }
  .header-nav .header-github-hot--nav { height: 30px; padding: 0 4px; }
  .header-nav .header-help--nav { height: 30px; padding: 0 6px; font-size: 13px; }
}

/* 窄屏顶栏：品牌固定靠左 */
@media (max-width: 720px) {
  .topbar-inner {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-areas: "brand actions" "nav nav" !important;
    align-items: center;
    column-gap: 10px;
    row-gap: 8px;
    height: auto !important;
    padding: 0 16px !important;
  }
  .topbar-inner .brand { grid-area: brand !important; justify-self: start !important; justify-content: flex-start !important; text-align: left !important; min-width: 0; overflow: hidden; white-space: nowrap; }
  .topbar-inner .header-tools { grid-area: actions !important; justify-self: end !important; margin-left: 0 !important; }
  .topbar-inner .header-nav { grid-area: nav !important; margin-left: 0 !important; }
}

/* 窄屏：GitHub / 帮助 固定第一行 */
@media (max-width: 720px) {
  .header-tools .header-github-hot { display: inline-flex !important; }
  .header-tools .header-help--desk { display: inline-flex !important; }
  .header-nav .header-github-hot--nav,
  .header-nav .header-help--nav { display: none !important; }
}

/* 窄屏导航字号统一 */
@media (max-width: 720px) {
  .header-nav .header-home,
  .header-nav .header-papers {
    font-size: 13px !important;
    padding: 0 8px !important;
    height: 32px;
  }
  .header-nav .header-github-hot--nav,
  .header-nav .header-help--nav { height: 32px; }
}

/* 窄屏两行：LoRA 固定在第一行、GitHub 左侧。
   本页选中链接是 href="index.html"，不能靠 href*=lora/ 识别。
   选中药丸更宽时仍留在第一行：品牌可压缩，LoRA 不换行、不缩。 */
@media (max-width: 720px) {
  .topbar,
  body.library-page .topbar {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  .topbar-inner,
  body.library-page .topbar-inner {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center;
    align-items: center;
    column-gap: 4px !important;
    row-gap: 8px;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    height: auto !important;
    overflow: visible !important;
    padding: 0 12px !important;
    box-sizing: border-box;
  }

  .topbar-inner .header-nav,
  body.library-page .topbar-inner .header-nav {
    display: contents !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
    width: auto !important;
  }

  .topbar-inner .brand,
  body.library-page .topbar-inner .brand {
    order: 1;
    flex: 1 1 0%;
    justify-self: start !important;
    justify-content: flex-start !important;
    text-align: left !important;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
  }

  .topbar-inner .header-nav > a.header-lora,
  .topbar-inner .header-nav > a.header-news,
  .topbar-inner .header-nav > a[data-i18n-aria="loraAria"],
  .topbar-inner .header-nav > a[aria-current="page"] {
    order: 2;
    flex: 0 0 auto;
    align-self: center;
    display: inline-flex !important;
    align-items: center;
    height: 32px;
    margin: 0 6px 0 8px;
    white-space: nowrap;
    min-width: max-content;
  }

  .topbar-inner .header-tools,
  body.library-page .topbar-inner .header-tools {
    order: 3;
    flex: 0 0 auto;
    justify-self: end !important;
    margin-left: 0 !important;
  }

  .topbar-inner::after {
    content: "";
    display: block;
    order: 4;
    flex: 0 0 100% !important;
    width: 0 !important;
    min-width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  /* 第二行五个链接必须同一行。英文 Home…Open Source 在约 392px 时，
     13px 字号 + 左右 8px 内边距会多出一行；收到 4px 后能放下，含选中加粗。 */
  .topbar-inner .header-nav > a:not(.header-lora):not(.header-news):not([data-i18n-aria="loraAria"]):not([aria-current="page"]) {
    order: 5;
    flex: 0 0 auto;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0 4px !important;
    font-size: 13px !important;
    max-width: 100%;
    white-space: nowrap;
  }
}
