:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e5e8ec;
  --text: #24292f;
  --muted: #6a737d;
  --accent: #0b66c3;
  --accent-soft: #e8f1fb;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

#app {
  display: flex;
  height: 100vh;
}

/* ---------- 左侧目录 ---------- */

#sidebar {
  width: 300px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.side-head {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--line);
}

.site-title {
  font-size: 17px;
  font-weight: 700;
}

.site-count {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 12px;
}

#filter {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: var(--bg);
  color: var(--text);
}

#filter:focus {
  border-color: var(--accent);
  background: #fff;
}

#list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.45;
}

.item:hover {
  background: #eef2f6;
}

.item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.item .num {
  flex: none;
  min-width: 32px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.item.active .num {
  color: var(--accent);
}

.item .t {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 右侧正文 ---------- */

#main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

#crumb {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

#copyBtn {
  flex: none;
  border: none;
  color: #fff;
  background: var(--accent);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

#copyBtn:hover {
  background: #095aa8;
}

#copyBtn:disabled {
  opacity: 0.6;
  cursor: default;
}

#content {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 28px 80px;
  font-size: 15.5px;
  line-height: 1.85;
}

#content .loading {
  color: var(--muted);
}

#content h1 {
  font-size: 26px;
  line-height: 1.4;
  margin: 8px 0 20px;
}

#content h2 {
  font-size: 21px;
  margin: 40px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

#content h3 {
  font-size: 17.5px;
  margin: 28px 0 10px;
}

#content h4 {
  font-size: 16px;
  margin: 22px 0 8px;
}

#content p {
  margin: 14px 0;
}

#content ul,
#content ol {
  padding-left: 1.6em;
  margin: 14px 0;
}

#content li {
  margin: 6px 0;
}

#content img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block;
  margin: 18px auto;
}

#content pre {
  background: #0d1117;
  color: #e6edf3;
  padding: 16px 18px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
  margin: 18px 0;
}

#content code {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
}

#content :not(pre) > code {
  background: #eef1f4;
  border: 1px solid #e2e6ea;
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 0.88em;
  color: #c7254e;
}

#content blockquote {
  margin: 16px 0;
  padding: 10px 16px;
  border-left: 4px solid var(--accent);
  background: #f2f7fd;
  border-radius: 0 8px 8px 0;
  color: #45505b;
}

#content blockquote p {
  margin: 4px 0;
}

#content table {
  border-collapse: collapse;
  width: 100%;
  margin: 18px 0;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}

#content th,
#content td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
}

#content th {
  background: #f3f5f7;
  white-space: nowrap;
}

#content tr:nth-child(2n) td {
  background: #fafbfc;
}

#content hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 36px 0;
}

/* 代码高亮（github-dark 配色） */
.hljs-comment,
.hljs-quote {
  color: #8b949e;
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag {
  color: #ff7b72;
}

.hljs-string,
.hljs-regexp,
.hljs-addition {
  color: #a5d6ff;
}

.hljs-number,
.hljs-literal {
  color: #79c0ff;
}

.hljs-title,
.hljs-title.function_,
.hljs-section {
  color: #d2a8ff;
}

.hljs-title.class_,
.hljs-type,
.hljs-built_in {
  color: #ffa657;
}

.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-template-variable,
.hljs-params {
  color: #79c0ff;
}

.hljs-meta,
.hljs-symbol,
.hljs-bullet,
.hljs-link {
  color: #ffa657;
}

.hljs-deletion {
  color: #ffa198;
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: 700;
}

/* ---------- 上一篇 / 下一篇 ---------- */

.pager {
  display: flex;
  gap: 14px;
  margin-top: 56px;
}

.pager-link {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pager-link:hover {
  border-color: var(--accent);
}

.pager-link.right {
  text-align: right;
}

.pager-link small {
  color: var(--muted);
  font-size: 12px;
}

.pager-link span {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pager-link.empty {
  opacity: 0.45;
  pointer-events: none;
}

/* ---------- 杂项 ---------- */

#menuBtn {
  display: none;
}

#scrim {
  display: none;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%) translateY(16px);
  background: #24292f;
  color: #fff;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
  max-width: 80vw;
  z-index: 99;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 900px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.18);
  }

  body.side-open #sidebar {
    transform: none;
  }

  #scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: 0.25s;
  }

  body.side-open #scrim {
    opacity: 1;
    pointer-events: auto;
  }

  #menuBtn {
    display: block;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 30;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--panel);
    font-size: 17px;
    cursor: pointer;
  }

  #topbar {
    padding-left: 58px;
  }

  #content {
    padding: 24px 18px 64px;
  }
}
