/* 「知识库与检索」一节：三个可操作演示 */
.lib {
  padding-block: 120px 40px;
}
.lib-rows {
  display: grid;
  gap: 88px;
  margin-top: 64px;
}
.lib-row {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.5fr);
  gap: 56px;
  align-items: center;
}
.lib-row.rev {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 0.8fr);
}
.lib-row.rev .lib-cap {
  order: 2;
}
.lib-cap .stg {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.lib-cap h3 {
  margin: 0 0 12px;
  font-size: clamp(24px, 2.6vw, 32px);
  letter-spacing: -0.025em;
  line-height: 1.2;
}
.lib-cap p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.75;
  text-wrap: pretty;
}
.lib-demo {
  min-width: 0;
  position: relative;
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-window);
  overflow: hidden;
  height: 360px;
  font-size: 13px;
  line-height: 1.6;
}
.lib-demo svg.ico {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lib-demo button {
  font: inherit;
  color: inherit;
}
.lib-demo mark {
  background: var(--highlight);
  color: #fff;
  border-radius: 3px;
  padding: 0 1px;
}
:root[data-theme='dark'] .lib-demo mark {
  color: #16171a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .lib-demo mark {
    color: #16171a;
  }
}

/* 搜索面板 */
.lb-pal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
  height: 100%;
}
.lb-pl {
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.lb-q {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 8px;
  color: var(--text-muted);
}
.lb-q input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 15px;
  color: var(--text-primary);
  caret-color: var(--text-primary);
}
.lb-q input::placeholder {
  color: var(--text-muted);
}
.lb-fl {
  display: flex;
  gap: 2px;
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--line-subtle);
  overflow-x: auto;
  scrollbar-width: none;
}
.lb-fl button {
  flex: none;
  border: 0;
  background: transparent;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.lb-fl button:hover {
  color: var(--text-secondary);
}
.lb-fl button.on {
  background: var(--bg-active);
  color: var(--text-primary);
}
.lb-rs {
  flex: 1;
  min-height: 0;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.lb-r {
  display: flex;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.lb-r:hover {
  background: var(--bg-hover);
}
.lb-r.on {
  background: var(--bg-active);
}
.lb-r svg {
  margin-top: 3px;
  color: var(--text-muted);
}
.lb-r b {
  color: var(--text-primary);
  font-weight: 500;
  margin-right: 6px;
}
.lb-r small {
  color: var(--text-muted);
  font-size: 11.5px;
}
.lb-r p {
  margin: 1px 0 0;
  font-size: 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lb-hint {
  padding: 34px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
}
.lb-ft {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--line-subtle);
  white-space: nowrap;
}
.lb-pr {
  padding: 18px 20px;
  min-width: 0;
  overflow: hidden;
}
.lb-ph {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.lb-ph b {
  font-size: 15px;
  font-weight: 600;
}
.lb-go {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  background: var(--accent);
  color: var(--accent-on);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
}
.lb-go svg {
  width: 12px !important;
  height: 12px !important;
}
.lb-pr small {
  color: var(--text-muted);
  font-size: 12px;
}
.lb-pc {
  margin-top: 16px;
  border: 1px solid var(--line-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  line-height: 1.75;
  font-size: 14px;
}

/* 资料页 */
.lb-mats {
  position: relative;
  height: 100%;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lb-mhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.lb-mhead b {
  display: block;
  font-size: 20px;
  line-height: 1.3;
}
.lb-mhead small {
  color: var(--text-muted);
  font-size: 12px;
}
.lb-mtools {
  display: flex;
  gap: 8px;
  align-items: center;
}
.lb-seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--bg-elevated);
}
.lb-seg button {
  border: 0;
  background: transparent;
  padding: 4px 11px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.lb-seg.icos button {
  padding: 4px 8px;
  display: grid;
  place-items: center;
}
.lb-seg button:hover {
  color: var(--text-secondary);
}
.lb-seg button.on {
  background: var(--bg-panel);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.lb-mbody {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.lb-mbody.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: max-content;
  gap: 14px;
}
.lb-mbody.list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lb-m {
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
  min-width: 0;
  border-radius: 12px;
  transition: transform var(--dur-base) var(--ease-out);
}
.lb-mbody.grid .lb-m:hover {
  transform: translateY(-2px);
}
.lb-mbody.list .lb-m {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
}
.lb-mbody.list .lb-m:hover {
  background: var(--bg-hover);
}
.lb-mn {
  display: block;
  min-width: 0;
}
.lb-mn b {
  display: block;
  font-weight: 500;
  font-size: 12px;
  margin-top: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-mbody.list .lb-mn b {
  margin: 0;
  font-size: 13px;
}
.lb-mn small {
  color: var(--text-muted);
  font-size: 11px;
}
.lb-ext {
  flex: none;
  font: 600 9.5px var(--font-sans);
  font-style: normal;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: 5px;
  padding: 2px 7px;
}
.lb-th {
  position: relative;
  height: 132px;
  border-radius: 12px;
  border: 1px solid var(--line-subtle);
  background: #fff;
  color: #1a1b1e;
  padding: 32px 11px 0;
  overflow: hidden;
}
.lb-th.slides,
.lb-th.doc {
  background: linear-gradient(90deg, #e6e6e9, #f4f4f6);
}
.lb-th i {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #3a3b3f;
  color: #fff;
  font: 600 9px var(--font-sans);
  font-style: normal;
  padding: 2px 6px;
  border-radius: 5px;
}
.lb-th h6 {
  margin: 0;
  font-size: 10px;
  line-height: 1.35;
}
.lb-th p {
  margin: 4px 0 0;
  font-size: 7.5px;
  line-height: 1.5;
  color: #666;
}
.lb-viewer {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: #16171a;
  color: #ecedef;
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lb-viewer[hidden] {
  display: none;
}
.lb-vh {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}
.lb-back,
.lb-vn button {
  border: 0;
  background: transparent;
  color: #9a9da4;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.lb-back:hover,
.lb-vn button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: #ecedef;
}
.lb-vn button:disabled {
  opacity: 0.3;
  cursor: default;
}
.lb-vn {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #9a9da4;
}
.lb-sheet {
  flex: 1;
  min-height: 0;
  background: #fff;
  color: #1a1b1e;
  border-radius: 10px;
  padding: 22px 28px;
  overflow: hidden;
}
.lb-sheet h4 {
  margin: 0 0 12px;
  font-size: 22px;
  line-height: 1.3;
}
.lb-sheet p {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
}
.lb-hit {
  background: #ffe9a6;
  color: #5c4308;
  border-radius: 3px;
  padding: 0 2px;
  animation: lb-hit 900ms var(--ease-out) both;
}
@keyframes lb-hit {
  from {
    background: transparent;
  }
}

/* 选中文字 */
.lb-sel {
  position: relative;
  height: 100%;
  background: #16171a;
  color: #ecedef;
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lb-sh {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
}
.lb-sh span {
  font-size: 12px;
  color: #9a9da4;
}
.lb-paper {
  flex: 1;
  min-height: 0;
  background: #fff;
  color: #1a1b1e;
  border-radius: 10px;
  padding: 24px 30px;
  overflow: hidden;
}
.lb-paper h4 {
  margin: 0 0 14px;
  font-size: 24px;
  line-height: 1.3;
}
.lb-paper p {
  margin: 0;
  font-size: 16px;
  line-height: 1.85;
}
.lb-paper ::selection {
  background: #2f66d0;
  color: #fff;
}
.lb-tb,
.lb-tr,
.lb-toast {
  position: absolute;
  z-index: 3;
  background: #f0f0f2;
  color: #444;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(0, 0, 0, 0.05);
}
.lb-tb[hidden],
.lb-tr[hidden],
.lb-toast[hidden] {
  display: none;
}
.lb-tb {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
}
.lb-tb button {
  position: relative;
  width: 32px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: #555;
  transition: background var(--dur-fast) var(--ease-out);
}
.lb-tb button:hover {
  background: #e1e1e4;
  color: #111;
}
.lb-tb button::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 8px;
  border-radius: 6px;
  background: #2a2b2f;
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out);
}
@media (hover: hover) {
  .lb-tb button:hover::after {
    opacity: 1;
    transition-delay: 300ms;
  }
}
.lb-tr {
  width: min(300px, calc(100% - 32px));
  padding: 12px 14px 8px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.65;
}
.lb-tr p {
  margin: 0;
}
.lb-ta {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
}
.lb-ta button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #888;
  cursor: pointer;
}
.lb-ta button:hover {
  background: #e1e1e4;
  color: #222;
}
.lb-toast {
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  white-space: nowrap;
}
.lb-hintl {
  position: absolute;
  right: 26px;
  bottom: 24px;
  font-size: 11.5px;
  color: #8a8d93;
  transition: opacity var(--dur-slow) var(--ease-out);
}
.lb-hintl.off {
  opacity: 0;
}

@media (max-width: 900px) {
  .lib-rows {
    gap: 56px;
  }
  .lib-row,
  .lib-row.rev {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
  .lib-row.rev .lib-cap {
    order: 0;
  }
  .lb-pal {
    grid-template-columns: minmax(0, 1fr);
  }
  .lb-pr {
    display: none;
  }
  .lib-demo {
    height: 380px;
  }
  .lb-mbody.grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (prefers-reduced-motion: reduce) {
  .lb-m,
  .lb-fl button,
  .lb-seg button {
    transition-duration: 1ms;
  }
}
.lib-demo[data-lib='search'] {
  height: 400px;
}
.lib-demo[data-lib='mats'] {
  height: 440px;
}
.lb-th {
  height: 118px;
}

/* 补充：无脚本时隐藏、滚动、提问条、对比度 */
.lib-demo[hidden],
html:not(.js) .lib-demo {
  display: none;
}
.lb-rs {
  overflow-y: auto;
  scrollbar-width: none;
}
.lb-rs::-webkit-scrollbar,
.lb-mbody::-webkit-scrollbar {
  display: none;
}
.lb-mbody {
  overflow-y: auto;
  scrollbar-width: none;
}
.lb-paper .fake {
  background: #2f66d0;
  color: #fff;
}
.lb-askbar {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 18px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  border-radius: var(--radius-md);
  background: #f0f0f2;
  color: #444;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  font-size: 12.5px;
}
.lb-askbar[hidden] {
  display: none;
}
.lb-quote {
  max-width: 62%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 6px;
  background: #e1e1e4;
  color: #333;
}
.lb-askph {
  color: #888;
}
.lb-send {
  margin-left: auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #2a2b2f;
  color: #fff;
  opacity: 0.35;
}
.lb-send svg {
  width: 13px;
  height: 13px;
}
.lb-hintl {
  color: #767a80;
  background: #fff;
  padding-left: 8px;
}
/* 搜索高亮：深一点的金色，白字对比度够；深色主题下用亮金配深字 */
.lib-demo mark {
  background: #8c6a28;
}
:root[data-theme='dark'] .lib-demo mark {
  background: var(--highlight);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .lib-demo mark {
    background: var(--highlight);
  }
}
.lb-r.on {
  outline: 0;
}
/* 课件查看器、选中文字演示固定为深色阅读器底，纸面始终是白色，有意不随主题变 */
@media (max-width: 900px) {
  .lb-mbody.grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .lb-mbody.grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (prefers-reduced-motion: reduce) {
  .lb-hit {
    animation: none;
  }
}
