/* ==========================================================================
   米虫博客 DEMO - 共享样式
   暗色模式 · 极简 · 科技蓝 · 无图
   ========================================================================== */

:root {
  --bg: #0d1117;
  --bg-alt: #11161d;
  --bg-code: #161b22;
  --border: #232a34;
  --text: #c9d1d9;
  --text-strong: #e6edf3;
  --text-muted: #7d8590;
  --accent: #58a6ff;        /* 科技蓝 */
  --accent-dim: #388bfd;
  --accent-soft: rgba(88, 166, 255, 0.12);
  --max-width: 960px;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-dim);
  text-decoration: underline;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* --------------------------------------------------------- 导航（无固定、无风格，仅横线分割） */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.nav .logo {
  display: inline-flex;
  align-items: center;
  height: 40px;
  color: var(--text-strong);
}

.nav .logo img {
  height: 40px;
  width: auto;
  display: block;
}

.nav .logo:hover {
  text-decoration: none;
}

.nav .links {
  display: flex;
  align-items: center;
}

.nav .links a {
  margin-left: 18px;
  height: 40px;
  line-height: 40px;
  color: var(--text);
}

.nav .links a:first-child {
  margin-left: 0;
}

/* --------------------------------------------------------- 首页简介 */
.intro {
  padding: 34px 0 8px;
}

.intro h1 {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-strong);
  margin: 0 0 18px;
}

.intro p {
  margin: 6px 0;
  color: var(--text);
}

/* --------------------------------------------------------- 三区块 */
.blocks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  padding: 28px 0;
}

.block h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-strong);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.block ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.block li {
  margin: 0;
  padding: 5px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.block li a {
  display: block;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------------------- 搜索框 */
.search-bar {
  display: flex;
  gap: 10px;
  padding: 28px 0 8px;
  max-width: 50%;
}

@media (max-width: 760px) {
  .search-bar {
    max-width: 100%;
  }
}

.search-bar input[type="text"] {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-strong);
  padding: 10px 2px;
  font-size: 15px;
  outline: none;
}

.search-bar input[type="text"]:focus {
  border-bottom-color: var(--accent);
}

/* 链接式按钮：无背景、无边框、无圆角 */
.btn,
.link-btn {
  background: none;
  border: none;
  border-radius: 0;
  color: var(--accent);
  padding: 10px 2px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s;
}

.btn:hover,
.link-btn:hover {
  color: var(--accent-dim);
}

.link-btn {
  font-size: 17px;
  font-weight: 700;
}

/* --------------------------------------------------------- 标签胶囊 */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 28px 0 8px;
}

.tag {
  font-size: 14px;
  color: var(--accent);
}

.tag:hover {
  color: var(--accent-dim);
  text-decoration: none;
}

/* --------------------------------------------------------- 首页友链（居左，页脚上方） */
.home-links {
  padding: 24px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  text-align: left;
}

.home-links a {
  margin: 0 6px;
}

.home-links a:first-of-type {
  margin-left: 4px;
}

/* --------------------------------------------------------- 页脚 */
.foot {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 26px 0 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.foot p {
  margin: 6px 0;
}

.foot .foot-tags a,
.foot .foot-links a {
  margin: 0 6px;
}

/* --------------------------------------------------------- 文章详情：两栏 */
.article-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 0;
  padding: 30px 0;
}

.article-main {
  padding-right: 32px;
  min-width: 0;
}

.article-toc {
  border-left: 1px solid var(--border);
  padding-left: 24px;
}

.article-toc .toc-title {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 12px;
}

.article-toc nav {
  position: sticky;
  top: 20px;
}

.article-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: none;
}

.article-toc li {
  padding: 4px 0;
  font-size: 13px;
}

.article-toc li.lv2 {
  padding-left: 14px;
}

.article-toc a {
  color: var(--text-muted);
}

.article-toc a:hover {
  color: var(--accent);
  text-decoration: none;
}

.article-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-strong);
  margin: 0 0 14px;
  line-height: 1.3;
}

.article-tags {
  margin: 0 0 12px;
}

.article-tags a {
  font-size: 14px;
  color: var(--accent);
  margin-right: 14px;
}

.article-tags a:hover {
  color: var(--accent-dim);
  text-decoration: none;
}

.article-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.article-meta span {
  margin-right: 16px;
}

.article-summary {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.8;
  margin: 0 0 20px;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
}

/* --------------------------------------------------------- Markdown 渲染风格 */
.md {
  color: var(--text);
}

.md h1,
.md h2,
.md h3,
.md h4 {
  color: var(--text-strong);
  font-weight: 600;
  line-height: 1.3;
  margin: 30px 0 14px;
}

.md h1 { font-size: 24px; }
.md h2 {
  font-size: 20px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.md h3 { font-size: 17px; }

.md p {
  margin: 14px 0;
}

.md a {
  text-decoration: underline;
}

.md ul,
.md ol {
  padding-left: 24px;
  margin: 14px 0;
}

.md li {
  margin: 6px 0;
}

.md blockquote {
  margin: 16px 0;
  padding: 4px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-muted);
}

.md code {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  color: #79c0ff;
}

.md pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow: auto;
  margin: 16px 0;
}

.md pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}

.md table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
  font-size: 14px;
}

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

.md th {
  background: var(--bg-code);
  color: var(--text-strong);
}

.md hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 26px 0;
}

/* --------------------------------------------------------- 点赞 */
.like-box {
  text-align: left;
  margin: 40px 0;
}

.like-btn {
  background: none;
  border: none;
  color: var(--accent);
  border-radius: 0;
  padding: 10px 0;
  font-size: 15px;
  cursor: pointer;
  transition: color 0.15s;
}

.like-btn:hover {
  color: var(--accent-dim);
}

/* 已点赞：置灰、禁用态，明显区别于可点击状态 */
.like-btn.liked,
.like-btn[disabled] {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.like-btn.liked:hover,
.like-btn[disabled]:hover {
  color: var(--text-muted);
}

.like-btn .count {
  font-weight: 700;
  margin-left: 6px;
}

/* --------------------------------------------------------- 更多推荐 */
.recommend h2 {
  font-size: 16px;
  color: var(--text-strong);
  margin: 30px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.recommend .rec-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 28px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.recommend .rec-grid li {
  padding: 5px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recommend .rec-grid li a {
  font-size: 14px;
}

/* --------------------------------------------------------- 搜索文章列表（无区块标题，3列直接展示） */
.search-list {
  padding: 20px 0;
}

.search-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 28px;
}

.search-list li {
  padding: 5px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-list li a {
  font-size: 14px;
}

@media (max-width: 760px) {
  .search-list ul {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------- 搜索结果提示 */
.search-hint {
  font-size: 14px;
  color: var(--text-muted);
  padding: 16px 0 4px;
}

.search-hint b {
  color: var(--accent);
}

/* --------------------------------------------------------- 友链 */
.friend-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
  padding: 28px 0;
}

.friend-item .name {
  font-size: 15px;
  font-weight: 600;
}

.friend-item .desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.friend-apply-bar {
  padding: 10px 0 4px;
}

.friend-apply-bar a {
  font-size: 17px;
  font-weight: 700;
}

/* --------------------------------------------------------- 表单 */
.form {
  max-width: 520px;
  padding: 30px 0;
}

.form .field {
  margin-bottom: 18px;
}

.form label {
  display: block;
  font-size: 14px;
  color: var(--text-strong);
  margin-bottom: 6px;
}

.form input[type="text"],
.form input[type="url"],
.form input[type="email"],
.form textarea,
.reply-form input[type="text"],
.reply-form textarea {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-strong);
  padding: 10px 2px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.form input:focus,
.form textarea:focus,
.reply-form input:focus,
.reply-form textarea:focus {
  border-bottom-color: var(--accent);
}

.form textarea,
.reply-form textarea {
  min-height: 100px;
  resize: vertical;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-strong);
  margin: 30px 0 4px;
}

.tag-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.back-link {
  display: inline-block;
  margin: 20px 0 0;
  font-size: 17px;
  font-weight: 700;
}

/* --------------------------------------------------------- 留言板 BBS 风格 */
.bbs {
  margin-top: 20px;
}

.bbs-item {
  padding: 18px 0;
  border-top: 1px solid var(--border);
}

/* 待审核的个人留言（仅自己可见）：虚线框 + 略降低透明度以区别于公开留言 */
.bbs-pending {
  margin-top: 12px;
}

.bbs-pending .bbs-pending-item {
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 10px;
  opacity: 0.85;
}

.bbs-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.bbs-nick {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
}

.bbs-nick em {
  font-style: normal;
  font-size: 12px;
  color: var(--accent);
}

.bbs-time {
  font-size: 12px;
  color: var(--text-muted);
}

.bbs-body {
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.bbs-actions {
  margin-top: 6px;
}

.bbs-actions .reply-toggle {
  font-size: 13px;
}

/* 回复（缩进 + 左侧线） */
.bbs-replies {
  margin: 10px 0 0 18px;
  border-left: 1px solid var(--border);
  padding-left: 16px;
}

.bbs-reply {
  padding: 10px 0;
}

.bbs-reply:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

/* 回复框 */
.reply-form {
  margin: 12px 0 0 18px;
  max-width: 520px;
}

.reply-form .field {
  margin-bottom: 12px;
}

/* --------------------------------------------------------- 移动端 TOC 悬浮按钮 + 目录浮层（默认桌面端隐藏） */
.toc-fab {
  display: none;
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 90;
  height: 36px;
  padding: 0 16px;
  border-radius: 18px;
  border: none;
  background: var(--bg-code);
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}

.toc-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: flex-end;
  /* 遮罩淡入淡出 */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.toc-overlay.open {
  opacity: 1;
  visibility: visible;
}

.toc-sheet {
  width: 75%;
  height: 100%;
  overflow: auto;
  background: var(--bg-alt);
  border-left: 1px solid var(--border);
  padding: 20px;
  /* 抽屉从右侧滑入滑出 */
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.toc-overlay.open .toc-sheet {
  transform: translateX(0);
}

.toc-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.toc-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.toc-sheet ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-sheet li {
  padding: 6px 0;
  font-size: 14px;
}

.toc-sheet li.lv2 {
  padding-left: 14px;
}

.toc-sheet a {
  color: var(--text);
}

/* --------------------------------------------------------- 响应式 */
@media (max-width: 760px) {
  /* 移动端：LOGO 独占一行，导航按钮换行到 LOGO 下方 */
  .nav .logo {
    flex: 0 0 100%;
  }
  .nav .links {
    flex: 0 0 100%;
  }
  /* 移动端导航按钮行高/高度降为 30px */
  .nav .links a {
    height: 30px;
    line-height: 30px;
  }
  .blocks {
    grid-template-columns: 1fr;
    gap: 22px;
  }
  .article-layout {
    grid-template-columns: 1fr;
  }
  .article-main {
    padding-right: 0;
  }
  /* 移动端隐藏右侧侧栏目录，改用悬浮按钮 + 浮层 */
  .article-toc {
    display: none;
  }
  .toc-fab {
    display: block;
  }
  .recommend .rec-grid {
    grid-template-columns: 1fr;
  }
  .friend-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
