:root {
  --knowledge-category-text: #182235;
  --knowledge-category-muted: #718096;
  --knowledge-category-border: #e1e8f0;
  --knowledge-category-accent: #4f6ff0;
  --knowledge-category-panel: rgba(255, 255, 255, .72);
}

body.knowledge-categories-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #eaf4fc 0%, #e8f2fb 48%, #e6f0f9 100%) !important;
  color: var(--knowledge-category-text);
}

body.knowledge-categories-page #headerSearchBtn,
body.knowledge-categories-page #desktopSearchBtn { display: none !important; }

.knowledge-categories-wrapper {
  width: min(1350px, calc(100vw - 340px));
  min-height: 100vh;
  margin-left: max(300px, calc(260px + (100vw - 1610px) / 2));
  padding: 54px 32px 64px;
}

.knowledge-categories-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .9fr);
  align-items: center;
  min-height: 340px;
  padding: 44px 52px 38px;
}

.knowledge-categories-hero__copy { min-width: 0; }
.knowledge-categories-header { width: 100%; margin: 0; text-align: left; }
.knowledge-categories-header h1 { margin: 0; font-size: clamp(2rem, 3.2vw, 2.75rem); line-height: 1.2; letter-spacing: -.05em; }
.knowledge-categories-header h1 span { background: linear-gradient(135deg, #f59e7c, #e8795a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.knowledge-categories-header p { margin: 14px 0 0; color: var(--knowledge-category-muted); font-size: .95rem; line-height: 1.65; }

.knowledge-categories-mobile-search { display: block; width: min(520px, 100%); margin: 30px 0 0; }
.knowledge-categories-mobile-search__field { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 15px; border: 1px solid rgba(148, 163, 184, .18); border-radius: 999px; background: rgba(255, 255, 255, .92); box-shadow: 0 4px 14px rgba(25, 45, 78, .05); }
.knowledge-categories-mobile-search__field:focus-within { border-color: rgba(59, 130, 246, .38); box-shadow: 0 6px 18px rgba(59, 130, 246, .12); }
.knowledge-categories-mobile-search__icon { display: inline-flex; flex: 0 0 24px; align-items: center; justify-content: center; width: 24px; height: 28px; padding: 0; border: 0; background: transparent; color: #3b82f6; cursor: pointer; }
.knowledge-categories-mobile-search__input { flex: 1; min-width: 0; width: 100%; height: 46px; padding: 0; border: 0; outline: 0; background: transparent; color: #475569; caret-color: #3b82f6; font: inherit; font-size: .9rem; }
.knowledge-categories-mobile-search__input::placeholder { color: #64748b; opacity: 1; }
.knowledge-categories-mobile-search__input:focus::placeholder { opacity: 0; }
.knowledge-categories-mobile-search__input::-webkit-search-cancel-button { display: none; }
.knowledge-categories-mobile-search__submit { flex: 0 0 auto; height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: #3b82f6; color: #fff; cursor: pointer; font: inherit; font-size: .78rem; line-height: 1; }
.knowledge-categories-mobile-search__submit:hover { background: #2563eb; }
.knowledge-categories-mobile-search__tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.knowledge-categories-mobile-search__tag { max-width: 130px; overflow: hidden; padding: 4px 10px; border: 1px solid rgba(59, 130, 246, .18); border-radius: 999px; background: rgba(239, 246, 255, .72); color: #2563eb; cursor: pointer; font-size: .72rem; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }

.knowledge-categories-hero__art { display: flex; align-items: center; justify-content: center; min-width: 0; height: 100%; }
.knowledge-categories-hero__art img { display: block; width: min(100%, 490px); height: 300px; object-fit: contain; object-position: center; }

.knowledge-categories-directory { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 26px; width: 100%; }
.knowledge-category-card { position: relative; min-width: 0; height: 286px; transition: transform .2s ease; }
.knowledge-category-card:hover { transform: translateY(-2px); }
.knowledge-category-card__surface { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; border: 1px solid rgba(148, 163, 184, .16); border-radius: 10px; background: rgba(255, 255, 255, .82); box-shadow: 0 4px 14px rgba(30, 64, 110, .04); transition: box-shadow .2s ease; }
.knowledge-category-card:hover .knowledge-category-card__surface { box-shadow: 0 8px 20px rgba(30, 64, 110, .08); }
.knowledge-category-card { --knowledge-category-fold-size: 42px; }
/* 纸张本体裁出右下三角缺口；伪元素使用与缺口全等的镜像三角形，形成翻起的折角。 */
.knowledge-category-card::after { position: absolute; right: 0; bottom: 0; z-index: 3; width: var(--knowledge-category-fold-size); height: var(--knowledge-category-fold-size); background: #d6e3f1; clip-path: polygon(0 0, 100% 0, 0 100%); content: ''; pointer-events: none; }
.knowledge-category-card__surface { clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--knowledge-category-fold-size)), calc(100% - var(--knowledge-category-fold-size)) 100%, 0 100%); }
.knowledge-category-card__head { position: relative; display: flex; flex: 0 0 76px; align-items: center; gap: 12px; width: 100%; min-height: 76px; padding: 14px 22px; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; text-align: left; }
.knowledge-category-card__head::after { position: absolute; right: 22px; bottom: 0; left: 22px; height: 1px; background: var(--knowledge-category-border); content: ''; }
.knowledge-category-card__icon { display: grid; flex: 0 0 34px; place-items: center; width: 34px; height: 34px; overflow: hidden; border-radius: 9px; background: rgba(244, 247, 252, .84); color: var(--knowledge-category-accent); font-size: .98rem; }
.knowledge-category-card__icon img { width: 100%; height: 100%; object-fit: cover; }
.knowledge-category-card__icon.has-emoji { background: transparent; font-size: 1.45rem; line-height: 1; }
.knowledge-category-card__meta { min-width: 0; }
.knowledge-category-card__title { display: block; overflow: hidden; font-size: 1rem; font-weight: 700; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-category-card__count { display: block; margin-top: 3px; color: var(--knowledge-category-muted); font-size: .76rem; }
.knowledge-category-card__arrow { margin-left: auto; color: #c0c8d5; font-size: .78rem; }
.knowledge-category-card__items { --knowledge-entry-order-width: 28px; --knowledge-entry-gap: 10px; display: grid; flex: 1; align-content: start; grid-auto-rows: max-content; gap: 2px; padding: 13px 22px 8px; overflow: hidden; }
.knowledge-category-card__item:nth-child(n + 6) { display: none; }
.knowledge-category-card.is-expanded { height: auto; min-height: 286px; }
.knowledge-category-card.is-expanded .knowledge-category-card__surface { position: relative; min-height: 286px; }
.knowledge-category-card.is-expanded .knowledge-category-card__items { overflow: visible; }
.knowledge-category-card.is-expanded .knowledge-category-card__item:nth-child(n + 6) { display: flex; }
.knowledge-category-card__item { display: flex; align-items: center; gap: var(--knowledge-entry-gap); min-width: 0; padding: 4px 2px; color: #354156; font-size: .84rem; line-height: 1.55; text-decoration: none !important; }
.knowledge-category-card__item:hover { color: var(--knowledge-category-accent); }
.knowledge-category-card__order { display: inline-grid; flex: 0 0 var(--knowledge-entry-order-width); place-items: center; min-width: var(--knowledge-entry-order-width); height: 20px; border-radius: 5px; background: rgba(79, 111, 240, .09); color: #5b73c9; font-size: .66rem; font-weight: 750; letter-spacing: .03em; line-height: 1; }
.knowledge-category-card__item-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-category-card__footer { display: flex; align-items: center; gap: 12px; min-height: 42px; margin: 0 22px; padding-right: var(--knowledge-category-fold-size); color: #94a3b8; font-size: .72rem; line-height: 1; }
.knowledge-category-card__footer > span, .knowledge-category-card__corner-link { line-height: 1; white-space: nowrap; }
.knowledge-category-card__corner-link { display: inline-flex; align-items: center; gap: 5px; min-height: 0; padding: 0; border: 0; background: transparent; color: var(--knowledge-category-accent); cursor: pointer; font: inherit; font-size: .74rem; text-decoration: none; transition: color .2s ease; }
.knowledge-category-card__corner-link:hover { color: #1d4ed8; }
.knowledge-category-card__corner-link i { font-size: .58rem; }
.knowledge-categories-empty { grid-column: 1 / -1; padding: 28px; color: var(--knowledge-category-muted); text-align: center; }
.knowledge-categories-directory .knowledge-categories-empty:not(:only-child) { display: none; }

body.dark.knowledge-categories-page { background: #0b1120 !important; }
body.dark .knowledge-categories-header { color: #edf2fa; }
body.dark .knowledge-categories-header p, body.dark .knowledge-category-card__count, body.dark .knowledge-category-card__footer { color: #9aa8bd; }
body.dark .knowledge-categories-mobile-search__field { border-color: rgba(148, 163, 184, .2); background: rgba(30, 41, 59, .78); }
body.dark .knowledge-categories-mobile-search__input { color: #cbd5e1; caret-color: #60a5fa; }
body.dark .knowledge-categories-mobile-search__input::placeholder { color: #94a3b8; }
body.dark .knowledge-categories-mobile-search__submit { background: #2563eb; }
body.dark .knowledge-categories-mobile-search__tag { border-color: rgba(147, 197, 253, .28); background: rgba(59, 130, 246, .18); color: #bfdbfe; }
body.dark .knowledge-category-card__surface { border-color: rgba(148, 163, 184, .14); background: #1e293b; }
body.dark .knowledge-category-card::after { background: #334155; }
body.dark .knowledge-category-card__item { color: #cbd5e1; }
body.dark .knowledge-category-card__order { background: rgba(96, 165, 250, .16); color: #bfdbfe; }
body.dark .knowledge-category-card__head::after { background: rgba(148, 163, 184, .2); }
body.dark .knowledge-category-card__corner-link { color: #bfdbfe; }

@media (max-width: 1100px) {
  .knowledge-categories-wrapper { width: 100%; margin: 0; padding: 42px clamp(18px, 5vw, 40px) 52px; }
  .knowledge-categories-directory { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .knowledge-categories-hero { grid-template-columns: minmax(0, 1fr) minmax(280px, .8fr); padding-inline: 36px; }
}

@media (max-width: 700px) {
  .knowledge-categories-wrapper { padding-top: 28px; }
  .knowledge-categories-hero { position: relative; display: flex; min-height: 0; flex-direction: column; align-items: stretch; gap: 18px; padding: 28px 20px 18px; overflow: visible; border-radius: 18px; }
  .knowledge-categories-hero__copy { position: relative; z-index: 1; }
  .knowledge-categories-header { text-align: center; }
  .knowledge-categories-header h1 { font-size: 32px; }
  .knowledge-categories-header p { margin-top: 9px; font-size: .84rem; }
  .knowledge-categories-mobile-search { position: relative; z-index: 1; width: 100%; margin-top: 22px; }
  .knowledge-categories-mobile-search__tags { justify-content: flex-start; }
  .knowledge-categories-hero__art { position: absolute; z-index: 2; right: 12px; bottom: -54px; width: 132px; height: 96px; min-height: 0; pointer-events: none; }
  .knowledge-categories-hero__art img { width: 100%; height: 100%; object-fit: contain; object-position: center; }
  .knowledge-categories-directory { grid-template-columns: 1fr; gap: 14px; margin-top: 54px; }
  .knowledge-category-card { height: 278px; }
}
