/* 知识库浏览页样式 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Segoe UI", Roboto, sans-serif;
  background: #f7faf4; color: #2c3b23;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* 顶栏 */
header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px; background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(10px); border-bottom: 2px solid #e2f0d8;
}
.brand { font-weight: 800; font-size: 16px; color: #4b8a2f; text-decoration: none; }
.hdr-right { display: flex; align-items: center; gap: 10px; }
.chip {
  font-size: 12px; color: #6c7f62; background: #eef6e6;
  padding: 4px 10px; border-radius: 20px;
}
.ghost {
  font-size: 13px; font-weight: 600; color: #4b8a2f; background: #eef6e6;
  padding: 7px 13px; border-radius: 20px; text-decoration: none;
}
.ghost:active { transform: scale(.96); }

/* 搜索 */
.search-wrap {
  position: sticky; top: 55px; z-index: 15;
  padding: 12px 16px; background: #f7faf4;
}
.search-box {
  position: relative; max-width: 720px; margin: 0 auto;
  display: flex; align-items: center;
  background: #fff; border-radius: 14px; border: 2px solid #dcecd0;
  box-shadow: 0 3px 12px rgba(80, 110, 60, .06);
}
.search-box:focus-within { border-color: #8cc43f; }
.s-icon { padding-left: 14px; font-size: 15px; opacity: .55; }
#q {
  flex: 1; border: none; outline: none; background: none;
  padding: 13px 10px; font-size: 15px; font-family: inherit; color: #2c3b23;
}
#q::-webkit-search-cancel-button { display: none; }
.s-clear {
  padding: 0 14px; font-size: 20px; color: #a8b8a0; line-height: 1;
}

main { max-width: 720px; margin: 0 auto; padding: 4px 16px 70px; }

/* 分类卡片 */
.cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.cat {
  text-align: left; background: #fff; border-radius: 16px; padding: 14px 15px;
  border: 2px solid #edf5e6; transition: all .16s;
  box-shadow: 0 2px 10px rgba(80, 110, 60, .05);
}
.cat.on { border-color: #8cc43f; background: #f4fbea; }
.cat:active { transform: scale(.97); }
.c-name { font-size: 14px; font-weight: 700; color: #3d5a2e; margin-bottom: 4px; }
.c-desc { font-size: 11.5px; color: #93a389; line-height: 1.55; margin-bottom: 8px; }
.c-count { font-size: 11px; color: #7db83a; font-weight: 700; }

/* 筛选条 */
.filter {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #f0f8e7; border-radius: 12px; padding: 9px 13px;
  font-size: 12.5px; color: #5a7048; margin-bottom: 14px;
}
#btn-all {
  margin-left: auto; font-size: 12px; font-weight: 700; color: #4b8a2f;
  background: #fff; padding: 5px 11px; border-radius: 9px;
}

/* 结果 */
.results { display: flex; flex-direction: column; gap: 9px; }
.empty { text-align: center; font-size: 13px; color: #9aa898; padding: 40px 0; margin: 0; }
.res {
  text-align: left; background: #fff; border-radius: 14px; padding: 13px 15px;
  border: 1px solid #eef5e7; transition: all .14s;
  box-shadow: 0 2px 8px rgba(80, 110, 60, .04);
}
.res:active { transform: scale(.985); background: #fcfef9; }
.r-top { display: flex; gap: 7px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.r-cat {
  font-size: 10.5px; font-weight: 700; color: #4b8a2f;
  background: #eef6e6; padding: 2px 8px; border-radius: 8px;
}
.r-tag { font-size: 10.5px; color: #98a892; }
.r-title { font-size: 14.5px; font-weight: 700; color: #2f4227; line-height: 1.45; }
.r-sym { font-size: 12px; color: #8a9a80; margin-top: 5px; line-height: 1.5; }

/* 文章阅读 */
.reader {
  position: fixed; inset: 0; z-index: 60; background: #fff;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.reader-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
  border-bottom: 2px solid #e2f0d8;
}
#btn-close { font-size: 14px; font-weight: 700; color: #4b8a2f; }

/* markdown 正文 */
.md {
  max-width: 720px; margin: 0 auto; padding: 20px 18px 90px;
  font-size: 15px; line-height: 1.78; color: #33452a;
}
.md h1 { font-size: 21px; margin: 6px 0 16px; color: #2b3d22; line-height: 1.4; }
.md h2 {
  font-size: 17px; margin: 26px 0 10px; color: #3d5a2e;
  padding-left: 10px; border-left: 4px solid #8cc43f;
}
.md h3 { font-size: 15.5px; margin: 20px 0 8px; color: #44553a; }
.md h4 { font-size: 14.5px; margin: 16px 0 6px; color: #55704a; }
.md p { margin: 9px 0; }
.md ul, .md ol { margin: 9px 0; padding-left: 22px; }
.md li { margin: 5px 0; }
.md code {
  background: #f1f7ea; color: #3f6b28; padding: 1.5px 6px;
  border-radius: 5px; font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.md pre {
  background: #26301f; color: #e6f0dc; padding: 14px 15px;
  border-radius: 12px; overflow-x: auto; margin: 13px 0;
  font-size: 12.5px; line-height: 1.65;
}
.md pre code { background: none; color: inherit; padding: 0; font-size: 12.5px; }
.md blockquote {
  margin: 13px 0; padding: 10px 15px; background: #f7fbef;
  border-left: 4px solid #b8dd97; border-radius: 0 10px 10px 0;
  color: #5a7048; font-size: 14px;
}
.md hr { border: none; border-top: 1px solid #e8f0e0; margin: 22px 0; }
.md a { color: #4b8a2f; text-decoration: underline; }
.md table { border-collapse: collapse; width: 100%; margin: 13px 0; font-size: 13px; }
.md th, .md td { border: 1px solid #e3eedb; padding: 8px 10px; text-align: left; }
.md th { background: #f2f9ea; font-weight: 700; color: #3d5a2e; }

/* 吐司 */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 16px);
  background: rgba(45, 60, 38, .95); color: #fff; font-size: 13px;
  padding: 11px 20px; border-radius: 22px; opacity: 0; pointer-events: none;
  transition: all .26s; z-index: 200; max-width: 86vw; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 430px) {
  .cats { grid-template-columns: 1fr 1fr; }
  .md { font-size: 14.5px; padding: 16px 15px 90px; }
}
