/* 小猫助装 H5 用户手册 - 样式 */

:root {
  --theme: #3498df;
  --theme-light: #5dade2;
  --theme-bg: #eef6fd;
  --theme-border: #b8d8f0;

  --text: #1f2328;
  --text-soft: #57606a;
  --text-muted: #8b949e;

  --bg: #f6f8fa;
  --bg-elev: #ffffff;
  --bg-soft: #f1f3f5;

  --border: #e5e7eb;
  --border-strong: #d0d7de;

  --code-bg: #f6f8fa;
  --code-text: #1f2328;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.10);

  --radius: 10px;
  --radius-sm: 6px;
  --header-h: 56px;
  --sidebar-w: 280px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

/* ================== 重置 ================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--theme); text-decoration: none; }
a:hover { color: var(--theme-light); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button {
  font-family: inherit; font-size: inherit;
  border: none; background: none; cursor: pointer; color: inherit;
}
kbd {
  display: inline-flex; align-items: center;
  padding: 1px 6px; font-size: 11px;
  font-family: var(--font-mono); color: var(--text-muted);
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 3px; line-height: 1.4;
}

/* ================== 顶部栏 ================== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex; align-items: center;
  gap: 12px; padding: 0 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.menu-btn {
  display: none; padding: 8px;
  border-radius: var(--radius-sm); color: var(--text-soft);
}
.menu-btn:hover { background: var(--bg-soft); }
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 16px;
  color: var(--text); flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--theme), var(--theme-light));
  color: #fff; font-weight: 700; font-size: 14px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 6px rgba(52,152,223,.3);
}
.brand-name { font-size: 16px; }
.brand-version {
  font-size: 11px; color: var(--text-muted);
  background: var(--bg-soft); padding: 2px 6px;
  border-radius: 4px; font-weight: 400;
}
.search-box {
  flex: 1; max-width: 360px; margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--bg-soft); border: 1px solid transparent;
  border-radius: 20px; color: var(--text-muted);
  transition: all .2s;
}
.search-box:focus-within {
  background: var(--bg-elev);
  border-color: var(--theme); color: var(--text);
  box-shadow: 0 0 0 3px rgba(52,152,223,.12);
}
.search-box input {
  flex: 1; border: none; background: transparent;
  outline: none; font-size: 14px; color: var(--text);
  font-family: inherit; min-width: 0;
}
.search-box input::placeholder { color: var(--text-muted); }

/* ================== 布局 ================== */
.layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  position: fixed;
  top: var(--header-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  overflow-y: auto; padding: 20px 0 60px;
  z-index: 50;
  transition: transform .3s;
}
.sidebar-nav { padding: 0 4px; }
.nav-section { margin-bottom: 16px; }
.nav-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 0 16px 8px;
  margin: 0;
  cursor: default;
  user-select: none;
}
.nav-list {
  list-style: none; padding: 0; margin: 0;
}
.nav-item a {
  display: block;
  padding: 7px 16px;
  font-size: 14px;
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: all .15s;
  text-decoration: none;
}
.nav-item a:hover {
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
}
.nav-item a.active {
  background: var(--theme-bg);
  color: var(--theme);
  font-weight: 500;
  border-left-color: var(--theme);
}

/* 内容区 */
.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 48px 80px;
  max-width: 980px;
  display: flex;
  gap: 24px;
}
.article {
  flex: 1;
  min-width: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 48px;
  box-shadow: var(--shadow-sm);
}

/* 右侧锚点导航 */
.anchor-nav {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  font-size: 12px;
}
.anchor-title {
  font-weight: 600;
  color: var(--text-soft);
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.anchor-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.anchor-list a {
  display: block;
  padding: 4px 0 4px 8px;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.2s ease;
  line-height: 1.4;
}
.anchor-list a:hover {
  color: var(--theme);
  text-decoration: none;
}
.anchor-list a.active {
  color: var(--theme);
  border-left-color: var(--theme);
  font-weight: 500;
}
.anchor-list a[data-level="3"],
.anchor-list a[data-level="4"] {
  padding-left: 16px;
  font-size: 11px;
}
.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
}

/* ================== 文档排版 ================== */
.article h1 {
  font-size: 28px; font-weight: 700;
  margin: 0 0 24px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.article h2 {
  font-size: 22px; font-weight: 600;
  margin: 36px 0 16px;
  color: var(--text);
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.article h3 {
  font-size: 18px; font-weight: 600;
  margin: 28px 0 12px;
  color: var(--text);
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.article h4 {
  font-size: 16px; font-weight: 600;
  margin: 24px 0 8px;
}
.article p { margin: 12px 0; color: var(--text); }
.article ul, .article ol {
  margin: 12px 0; padding-left: 24px;
}
.article li { margin: 4px 0; }
.article blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--bg-soft);
  border-left: 3px solid var(--theme);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-soft);
}
.article blockquote p { margin: 4px 0; }
.article code {
  padding: 2px 6px;
  font-family: var(--font-mono); font-size: 13px;
  background: var(--code-bg); color: var(--code-text);
  border-radius: 3px;
}
.article pre {
  margin: 16px 0; padding: 16px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto; line-height: 1.5;
}
.article pre code {
  padding: 0; background: transparent;
  font-size: 13px; color: var(--text);
}
.article table {
  width: 100%; border-collapse: collapse;
  margin: 16px 0; font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.article thead { background: var(--theme-bg); }
.article th, .article td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left; vertical-align: top;
}
.article th {
  font-weight: 600; color: var(--text);
}
.article td { color: var(--text-soft); }
.article tr:nth-child(even) { background: #fafbfc; }
.article hr {
  border: 0; height: 1px;
  background: var(--border); margin: 32px 0;
}
.article img {
  display: block; max-width: 100%;
  margin: 16px auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
}
.article strong { font-weight: 600; color: var(--text); }

/* ================== 搜索结果浮层 ================== */
.search-results {
  position: fixed;
  top: calc(var(--header-h) + 8px);
  right: 16px; width: 420px;
  max-height: 70vh;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow-y: auto; z-index: 200;
  display: none;
}
.search-results.show { display: block; }
.search-result {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg-soft); }
.search-result-title {
  font-size: 14px; font-weight: 600;
  color: var(--text); margin-bottom: 4px;
}
.search-result-section {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .6px;
  margin-bottom: 4px;
}
.search-result-snippet {
  font-size: 13px; color: var(--text-soft);
  line-height: 1.5;
}
.search-result-snippet mark {
  background: #fff3a0; color: #5a4a00;
  padding: 0 2px; border-radius: 2px;
}
.search-empty {
  padding: 30px; text-align: center;
  color: var(--text-muted); font-size: 13px;
}

/* ================== Lightbox ================== */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.92);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; cursor: zoom-out; padding: 24px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.lightbox.active { display: flex; }
.lightbox img {
  max-width: 95%; max-height: 95%;
  border-radius: var(--radius-sm);
  cursor: default; border: none;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  width: 40px; height: 40px;
  background: rgba(255,255,255,.12);
  border: 0; color: #fff; font-size: 24px;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.lightbox-close:hover { background: rgba(255,255,255,.24); }

/* ================== 遮罩 ================== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 40; opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* ================== 响应式 ================== */
@media (max-width: 1024px) {
  .content { padding: 24px 28px 60px; }
  .article { padding: 32px; }
}

@media (max-width: 768px) {
  .menu-btn { display: inline-flex; }
  .brand-name { display: none; }
  .brand-version { display: none; }
  .search-box { max-width: 200px; }
  .search-box kbd { display: none; }

  .layout { padding-top: var(--header-h); }
  .sidebar {
    transform: translateX(-100%);
    width: 280px; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .content {
    margin-left: 0;
    padding: 16px 12px 60px;
    flex-direction: column;
  }
  .article { padding: 24px 18px; }
  .article h1 { font-size: 22px; }
  .article h2 { font-size: 19px; }
  .article h3 { font-size: 16px; }
  .article table { font-size: 13px; }
  .article th, .article td { padding: 8px 10px; }

  /* 移动端隐藏锚点导航 */
  .anchor-nav { display: none; }

  .search-results {
    right: 8px; left: 8px;
    width: auto; max-height: 60vh;
  }
}

@media (max-width: 480px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .search-box { max-width: 160px; padding: 5px 10px; }
  .search-box input { font-size: 13px; }
  .article { padding: 20px 14px; border-radius: var(--radius-sm); }
  .article h1 { font-size: 20px; margin-bottom: 16px; }
  .article h2 { font-size: 18px; margin: 24px 0 12px; }
  .article pre { font-size: 12px; }
  .content { padding: 12px 8px 60px; }
  .lightbox { padding: 12px; }
  .lightbox-close { top: 12px; right: 12px; }
}

/* ================== 滚动条 ================== */
.sidebar::-webkit-scrollbar,
.search-results::-webkit-scrollbar,
.article pre::-webkit-scrollbar {
  width: 6px; height: 6px;
}
.sidebar::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb,
.article pre::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ================== 打印 ================== */
@media print {
  .topbar, .sidebar, .search-results, .lightbox, .overlay { display: none !important; }
  .content { margin: 0; padding: 20px; max-width: 100%; }
  .article { border: none; box-shadow: none; padding: 0; }
  .article img { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
}
