/* ============================================================
   Personal Blog System - Cold Gray-White Theme
   Minimalist, cold, detached aesthetic
   ============================================================ */

:root {
  --bg-body: #f0f0f3;
  --bg-card: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.88);
  --bg-footer: #1c1e22;
  --bg-code: #f4f4f7;
  --bg-input: #f7f7fa;
  --text-primary: #2a2c32;
  --text-secondary: #5a5e6a;
  --text-muted: #8a8e9a;
  --text-inverse: #e0e0e4;
  --accent: #6b7280;
  --accent-hover: #4b5563;
  --accent-light: #e5e7eb;
  --accent-subtle: #f0f1f3;
  --border: #e2e4e8;
  --border-light: #ecedf0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei",
    sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
  color: var(--accent-hover);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul,
ol {
  list-style: none;
}

::selection {
  background-color: var(--accent);
  color: #fff;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.text-center {
  text-align: center;
}

.mt-20 {
  margin-top: 20px;
}

.mb-20 {
  margin-bottom: 20px;
}

/* ============================================================
   1. Site Header
   ============================================================ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-header);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-light);
  z-index: 100;
  height: 60px;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.header-logo {
  font-size: 1.35em;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.header-logo a {
  color: var(--text-primary);
  transition: color var(--transition);
}

.header-logo a:hover {
  color: var(--accent);
}

/* ============================================================
   2. Site Navigation
   ============================================================ */
.site-nav {
  display: flex;
  align-items: center;
}

.site-nav a {
  display: inline-block;
  padding: 8px 16px;
  color: var(--text-secondary);
  font-size: 0.92em;
  position: relative;
  letter-spacing: 0.01em;
  transition: color var(--transition);
}

.site-nav a:hover {
  color: var(--text-primary);
}

.site-nav a.active {
  color: var(--text-primary);
  font-weight: 600;
}

.site-nav a.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 1px;
}

/* ============================================================
   3. Hamburger Menu (Mobile)
   ============================================================ */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  z-index: 101;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background-color: var(--text-primary);
  margin: 3px 0;
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.hamburger.active span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* ============================================================
   Header Search
   ============================================================ */
.header-search {
  flex-shrink: 0;
  margin-right: 8px;
}

.header-search .search-box {
  display: flex;
  align-items: center;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-input);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.header-search .search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.header-search .search-input {
  width: 140px;
  padding: 7px 12px;
  font-size: 0.85em;
  border: none;
  background: transparent;
  color: var(--text-primary);
  outline: none;
}

.header-search .search-input:focus {
  width: 180px;
}

.header-search .search-btn {
  padding: 7px 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}

.header-search .search-btn:hover {
  color: var(--accent);
}

/* Mobile search inside nav */
.mobile-search {
  display: none;
  padding: 12px 0;
  border-top: 1px solid var(--border-light);
  margin-top: 8px;
}

.mobile-search .search-box {
  display: flex;
  margin: 0;
}

.mobile-search .search-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9em;
  border: 1px solid var(--border);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
}

.mobile-search .search-input:focus {
  border-color: var(--accent);
}

.mobile-search .search-btn {
  padding: 10px 16px;
  background: var(--text-primary);
  color: var(--bg-card);
  border: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  cursor: pointer;
  display: flex;
  align-items: center;
}

/* ============================================================
   4-6. Main Layout
   ============================================================ */
.main-container {
  display: flex;
  max-width: 1200px;
  margin: 80px auto 0 auto;
  gap: 30px;
  padding: 20px;
  min-height: calc(100vh - 60px - 200px);
}

.content-area {
  flex: 1;
  min-width: 0;
}

.sidebar {
  width: 300px;
  flex-shrink: 0;
}

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 1.6em;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9em;
  margin-top: 4px;
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 0.95em;
}

/* ============================================================
   7. Article List Items (Horizontal Layout)
   ============================================================ */
.article-item {
  background-color: var(--bg-card);
  margin-bottom: 18px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-light);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: row;
  padding: 12px;
  gap: 12px;
}

.article-item:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.article-cover {
  flex-shrink: 0;
  width: 240px;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.article-cover img {
  width: 100%;
  height: 100%;
  min-height: 160px;
  max-height: 180px;
  object-fit: cover;
  filter: saturate(0.85);
  transition: filter var(--transition), transform var(--transition);
  border-radius: var(--radius-md);
}

.article-item:hover .article-cover img {
  filter: saturate(1);
  transform: scale(1.03);
}

.article-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
}

/* Badge + Title on the same row (like reference) */
.article-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.article-category-badge {
  display: inline-block;
  background-color: var(--accent);
  color: #fff;
  font-size: 0.72em;
  padding: 3px 10px;
  border-radius: 4px;
  letter-spacing: 0.03em;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.article-title {
  font-size: 1.15em;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
  margin: 0;
}

.article-title a {
  color: var(--text-primary);
  transition: color var(--transition);
}

.article-title a:hover {
  color: var(--accent-hover);
}

.article-excerpt {
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  color: var(--text-muted);
  font-size: 0.85em;
  margin-top: 12px;
}

.article-meta span,
.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.85em;
}

.meta-icon {
  opacity: 0.55;
}

.article-meta-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  margin-top: 12px;
}

.meta-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.article-meta-bottom .meta-item {
  font-size: 0.78em;
  white-space: nowrap;
}

.meta-like-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border: 1px solid rgba(224, 69, 92, 0.35);
  border-radius: 999px;
  background: rgba(224, 69, 92, 0.05);
  color: #e0455c;
  font-family: inherit;
  font-size: 0.85em;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.meta-like-btn:hover {
  color: #c93a4e;
  border-color: rgba(224, 69, 92, 0.55);
  background: rgba(224, 69, 92, 0.12);
}

.meta-like-btn.active {
  color: #fff;
  border-color: #e0455c;
  background: #e0455c;
}

.read-more {
  font-size: 0.82em;
  color: var(--accent);
  white-space: nowrap;
  transition: color var(--transition);
  letter-spacing: 0.02em;
}

.read-more:hover {
  color: var(--accent-hover);
}

/* ============================================================
   8. Article Detail
   ============================================================ */
.article-detail {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 36px;
  border: 1px solid var(--border-light);
}

.article-detail .article-header {
  margin-bottom: 24px;
}

.article-detail .article-header .article-title {
  font-size: 1.8em;
  margin-bottom: 12px;
}

.article-detail .article-meta {
  margin-bottom: 16px;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.article-tags .tag,
.article-tag {
  display: inline-block;
  background-color: var(--accent-subtle);
  color: var(--accent);
  font-size: 0.8em;
  padding: 3px 12px;
  border-radius: 3px;
  transition: background-color var(--transition), color var(--transition);
  letter-spacing: 0.02em;
}

.article-tags .tag:hover,
.article-tag:hover {
  background-color: var(--accent-light);
  color: var(--accent-hover);
}

.article-content {
  line-height: 1.8;
  font-size: 1.05em;
  color: var(--text-primary);
  word-break: break-word;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
  margin-top: 1.5em;
  margin-bottom: 0.6em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

.article-content h2 {
  font-size: 1.5em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.article-content h3 {
  font-size: 1.25em;
}

.article-content p {
  margin-bottom: 1em;
}

.article-content img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 16px 0;
}

.article-content a {
  text-decoration: underline;
  text-underline-offset: 2px;
  color: var(--accent-hover);
}

.article-content a:hover {
  color: var(--text-primary);
}

.article-content pre {
  background-color: #282c34;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.9em;
  line-height: 1.6;
  margin: 16px 0;
  border: 1px solid #3a3f47;
  position: relative;
}

.article-content pre code {
  display: block;
  overflow-x: auto;
  padding: 0;
  background: none;
  border: none;
  color: #e4e4e7;
  font-size: inherit;
}

.article-content pre code.hljs {
  padding: 0;
  background: transparent;
  color: #e4e4e7;
}

/* hljs 语法高亮覆盖：正文白色、注释绿色 */
.article-content pre .hljs-comment,
.article-content pre .hljs-quote {
  color: #6a9955;
  font-style: italic;
}

.article-content pre .hljs-keyword,
.article-content pre .hljs-selector-tag {
  color: #c586c0;
}

.article-content pre .hljs-string,
.article-content pre .hljs-addition {
  color: #ce9178;
}

.article-content pre .hljs-number,
.article-content pre .hljs-literal {
  color: #b5cea8;
}

.article-content pre .hljs-built_in,
.article-content pre .hljs-type {
  color: #4ec9b0;
}

.article-content pre .hljs-function .hljs-title {
  color: #dcdcaa;
}

.article-content pre .hljs-variable,
.article-content pre .hljs-attr {
  color: #9cdcfe;
}

.article-content pre .hljs-symbol,
.article-content pre .hljs-bullet {
  color: #569cd6;
}

.article-content pre .hljs-meta {
  color: #569cd6;
}

.article-content pre .hljs-deletion {
  color: #f44747;
}

.article-content pre .hljs-section {
  color: #569cd6;
  font-weight: 600;
}

.article-content pre .hljs-emphasis {
  font-style: italic;
}

.article-content pre .hljs-strong {
  font-weight: 700;
}

.article-content code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono",
    "Courier New", monospace;
  font-size: 0.9em;
}

.article-content :not(pre) > code {
  background-color: var(--accent-subtle);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--accent-hover);
  font-size: 0.88em;
}

/* 代码块复制按钮 */
.article-content pre .code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: #adb5bd;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  font-family: inherit;
  line-height: 1;
}

.article-content pre:hover .code-copy-btn {
  opacity: 1;
}

.article-content pre .code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #e9ecef;
}

.article-content pre .code-copy-btn.copied {
  color: #51cf66;
  border-color: #51cf66;
}

.article-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  color: var(--text-secondary);
  margin: 16px 0;
  font-style: normal;
  background-color: var(--accent-subtle);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.article-content blockquote p {
  margin-bottom: 0;
}

.article-content ul,
.article-content ol {
  margin: 12px 0;
  padding-left: 24px;
}

.article-content ul {
  list-style: disc;
}

.article-content ol {
  list-style: decimal;
}

.article-content li {
  margin-bottom: 4px;
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

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

.article-content th {
  background-color: var(--accent-subtle);
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================================
   Rating Section
   ============================================================ */
.rating-section {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  padding: 12px 16px;
  background-color: var(--accent-subtle);
  border-radius: var(--radius-md);
  font-size: 0.9em;
}

.rating-label {
  color: var(--text-secondary);
}

.rating-score {
  font-weight: 600;
  color: var(--text-primary);
}

.rating-stars {
  display: flex;
  gap: 2px;
}

.rating-star {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2em;
  color: var(--border);
  transition: color var(--transition);
  padding: 0 1px;
}

.rating-star.active,
.rating-star:hover {
  color: var(--accent);
}

/* ============================================================
   9. Star Rating (CSS-Only)
   ============================================================ */
.star-rating {
  display: inline-flex;
  flex-direction: row-reverse;
  gap: 2px;
  font-size: 1.4em;
}

.star-rating input {
  display: none;
}

.star-rating label {
  cursor: pointer;
  color: var(--border);
  transition: color var(--transition);
}

.star-rating label::before {
  content: "\2605";
}

.star-rating input:checked ~ label,
.star-rating label:hover,
.star-rating label:hover ~ label {
  color: var(--accent);
}

/* ============================================================
   10. Comments Section
   ============================================================ */
.comment-success {
  padding: 12px 16px;
  margin-bottom: 20px;
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
  border-radius: var(--radius-md);
  font-size: 0.9em;
}

.comments-section {
  margin-top: 40px;
}

.comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.comments-title {
  font-size: 1.2em;
  font-weight: 600;
  color: var(--text-primary);
}

.comments-sort {
  display: flex;
  gap: 12px;
}

.sort-link {
  font-size: 0.85em;
  color: var(--text-muted);
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.sort-link:hover {
  color: var(--text-secondary);
}

.sort-link.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
  font-weight: 500;
}

.comment-form-wrap {
  background-color: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  margin-bottom: 24px;
}

.comment-form-title {
  font-size: 1em;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.comment-form {
  width: 100%;
}

.comment-form .form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.comment-form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.comment-input,
.comment-form input[type="text"],
.comment-form input[type="email"] {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.92em;
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--bg-input);
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
  outline: none;
}

.comment-input:focus,
.comment-form input:focus,
.comment-form textarea:focus,
.comment-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.1);
  background-color: var(--bg-card);
}

.comment-textarea,
.comment-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.92em;
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--bg-input);
  resize: vertical;
  min-height: 100px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.comment-submit-btn,
.comment-form button {
  margin-top: 12px;
  padding: 10px 28px;
  background-color: var(--text-primary);
  color: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.92em;
  cursor: pointer;
  transition: background-color var(--transition), transform var(--transition);
  letter-spacing: 0.02em;
}

.comment-submit-btn:hover,
.comment-form button:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.comment-list {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.comment-item {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  gap: 14px;
}

.comment-item:last-child {
  border-bottom: none;
}

.comment-avatar {
  flex-shrink: 0;
}

.comment-avatar img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  filter: grayscale(30%);
}

.comment-body {
  flex: 1;
  min-width: 0;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.comment-nickname,
.comment-item .comment-author {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.92em;
}

.comment-nickname a {
  color: var(--text-primary);
}

.comment-nickname a:hover {
  color: var(--accent-hover);
}

.comment-author-badge {
  display: inline-block;
  background-color: var(--accent);
  color: #fff;
  font-size: 0.68em;
  padding: 1px 8px;
  border-radius: 3px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.comment-time,
.comment-item .comment-time {
  font-size: 0.78em;
  color: var(--text-muted);
}

.comment-replyto {
  font-size: 0.78em;
  color: var(--accent);
  margin-left: 6px;
}
.comment-replyto::before {
  content: '↩ ';
}

.comment-content,
.comment-item .comment-body p,
.comment-item .comment-body {
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 1em;
}

.comment-content p {
  margin: 4px 0;
}
.comment-content p:first-child {
  margin-top: 0;
}
.comment-content p:last-child {
  margin-bottom: 0;
}
/* 评论区 markdown 渲染的标题：字号与评论正文统一，避免过大 */
.comment-content h1,
.comment-content h2,
.comment-content h3,
.comment-content h4,
.comment-content h5,
.comment-content h6 {
  font-size: 1em;
  font-weight: 600;
  color: var(--text-primary);
  margin: 8px 0 4px;
  line-height: 1.5;
}
.comment-content strong {
  font-weight: 600;
  color: var(--text-primary);
}
.comment-content code {
  background: rgba(0,0,0,0.05);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: Consolas, 'Courier New', monospace;
}
.comment-content pre {
  background: #f5f5f5;
  padding: 8px 12px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 6px 0;
}
.comment-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}
.comment-content ul,
.comment-content ol {
  margin: 4px 0;
  padding-left: 20px;
}
.comment-content li {
  margin: 2px 0;
}
.comment-content a {
  color: var(--accent);
  text-decoration: underline;
}
.comment-content blockquote {
  border-left: 3px solid var(--border);
  margin: 6px 0;
  padding: 4px 12px;
  color: var(--text-muted);
  background: var(--bg-card);
  border-radius: 0 4px 4px 0;
}
.comment-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}
.comment-content em {
  font-style: italic;
}

.comment-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.comment-action-btn,
.comment-actions button {
  background: none;
  border: 1px solid var(--border-light);
  font-size: 0.78em;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.comment-action-btn:hover,
.comment-actions button:hover {
  color: var(--text-secondary);
  border-color: var(--border);
  background-color: var(--accent-subtle);
}

.comment-actions .like-btn:hover,
.comment-action-btn.comment-like-btn:hover {
  color: var(--accent-hover);
}

.comment-action-btn.comment-like-btn.active,
.comment-action-btn.comment-like-btn.active:hover {
  color: #fff;
  border-color: #e0455c;
  background-color: #e0455c;
}

.comment-children {
  margin-left: 0;
  margin-top: 12px;
  padding-left: 20px;
  border-left: 2px solid var(--border);
}

.comment-reply-form {
  margin-top: 12px;
  padding: 16px;
  background-color: var(--accent-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

/* ============================================================
   11. Pagination
   ============================================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  margin: 30px 0;
}

/* 加载更多评论/回复按钮 */
.load-more-comments-wrap,
.load-more-replies-wrap {
  text-align: center;
  margin: 20px 0;
}
.load-more-comments-wrap {
  margin: 10px 0 30px;
}
.load-more-comments-btn,
.load-more-replies-btn {
  display: inline-block;
  padding: 8px 22px;
  font-size: 0.88em;
  color: var(--text-secondary);
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.load-more-comments-btn:hover,
.load-more-replies-btn:hover {
  color: var(--bg-card);
  background-color: var(--text-primary);
  border-color: var(--text-primary);
}
.load-more-replies-wrap {
  margin: 8px 0 2px;
}

.pagination a,
.pagination span,
.pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 0.88em;
  color: var(--text-secondary);
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  transition: all var(--transition);
}

.pagination a:hover {
  color: var(--bg-card);
  background-color: var(--text-primary);
  border-color: var(--text-primary);
}

.pagination .active,
.pagination-current {
  color: var(--bg-card);
  background-color: var(--text-primary);
  border-color: var(--text-primary);
  font-weight: 600;
}

.pagination .disabled {
  color: var(--border);
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  color: var(--text-muted);
}

.pagination-numbers {
  display: flex;
  gap: 5px;
}

/* ============================================================
   12. Gallery Grid
   ============================================================ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.gallery-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-light);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  display: block;
  color: var(--text-primary);
}

.gallery-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  color: var(--text-primary);
}

.gallery-card-cover {
  overflow: hidden;
}

.gallery-card-cover img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  filter: saturate(0.8);
  transition: filter var(--transition), transform var(--transition);
}

.gallery-card:hover .gallery-card-cover img {
  filter: saturate(1);
  transform: scale(1.03);
}

.gallery-card-placeholder {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-subtle);
}

.gallery-card-info,
.gallery-card-body {
  padding: 14px 16px;
}

.gallery-card-title {
  font-size: 1em;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.gallery-card-desc {
  font-size: 0.82em;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-card-date {
  font-size: 0.8em;
  color: var(--text-muted);
}

/* ============================================================
   Gallery Detail
   ============================================================ */
.gallery-detail {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 30px;
  border: 1px solid var(--border-light);
}

.gallery-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.gallery-title {
  font-size: 1.6em;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.gallery-desc {
  color: var(--text-secondary);
  font-size: 0.92em;
  line-height: 1.6;
}

.gallery-back-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.88em;
  color: var(--text-muted);
  transition: color var(--transition);
}

.gallery-back-link:hover {
  color: var(--text-primary);
}

/* 通用返回导航 */
.back-nav {
  margin-bottom: 12px;
}

.back-link {
  font-size: 0.88em;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.back-link:hover {
  color: var(--text-primary);
}

.gallery-image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.gallery-image-item {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-light);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.gallery-image-item:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
}

.gallery-image-link {
  display: block;
  overflow: hidden;
}

.gallery-image-link img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  filter: saturate(0.85);
  transition: filter var(--transition), transform var(--transition);
}

.gallery-image-item:hover .gallery-image-link img {
  filter: saturate(1);
  transform: scale(1.03);
}

.gallery-image-caption {
  padding: 8px 12px;
  font-size: 0.82em;
  color: var(--text-muted);
  text-align: center;
  background-color: var(--accent-subtle);
}

/* ============================================================
   13. Search Box
   ============================================================ */
.search-box {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
}

.search-box input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  font-size: 0.92em;
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--bg-card);
  outline: none;
  transition: border-color var(--transition);
}

.search-box input:focus {
  border-color: var(--accent);
}

.search-box button {
  padding: 10px 20px;
  background-color: var(--text-primary);
  color: var(--bg-card);
  border: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.92em;
  cursor: pointer;
  transition: background-color var(--transition);
  white-space: nowrap;
}

.search-box button:hover {
  background-color: var(--accent-hover);
}

/* ============================================================
   14. Sidebar
   ============================================================ */
.sidebar-card {
  background-color: var(--bg-card);
  padding: 18px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

.sidebar-card h4,
.sidebar-title {
  font-size: 0.92em;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.author-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 10px auto;
  border: 2px solid var(--border);
  filter: grayscale(40%);
  transition: filter var(--transition), border-color var(--transition);
}

.author-avatar:hover {
  filter: grayscale(0%);
  border-color: var(--accent);
}

.author-name {
  text-align: center;
  font-weight: 600;
  font-size: 1.05em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.author-bio {
  text-align: center;
  font-size: 0.85em;
  color: var(--text-muted);
  line-height: 1.5;
}

.recent-comments {
  list-style: none;
  padding: 0;
}

/* 最近评论：头像 + 昵称一行，时间右对齐，摘要独立成行，避免挤成一团 */
.rc-item {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border-light);
}

.rc-item:last-child {
  border-bottom: none;
}

.rc-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rc-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  filter: grayscale(30%);
}

.rc-item-info {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.rc-nickname {
  font-weight: 600;
  font-size: 0.88em;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rc-time {
  font-size: 0.72em;
  color: var(--text-muted);
  flex-shrink: 0;
}

.rc-article {
  margin: 4px 0 2px;
  font-size: 0.76em;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rc-article a {
  color: var(--accent);
  transition: color var(--transition);
}

.rc-article a:hover {
  color: var(--accent-hover);
}

.rc-snippet {
  margin: 2px 0 0;
  font-size: 0.84em;
  color: var(--text-secondary);
  line-height: 1.55;
  /* 多行截断，最多 2 行 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hot-articles {
  list-style: none;
  padding: 0;
}

.hot-item {
  padding: 6px 0;
  border-bottom: 1px dashed var(--border-light);
}

.hot-item:last-child {
  border-bottom: none;
}

.hot-item a {
  font-size: 0.88em;
  color: var(--text-secondary);
  transition: color var(--transition);
  display: block;
  padding: 2px 0;
}

.hot-item a:hover {
  color: var(--text-primary);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-cloud a,
.tag-item {
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 12px;
  transition: all var(--transition);
  font-size: 0.85em;
}

.tag-cloud a:hover,
.tag-item:hover {
  color: var(--bg-card);
  background-color: var(--text-primary);
  border-color: var(--text-primary);
}

.tag-cloud .tag-small {
  font-size: 0.8em;
}

.tag-cloud .tag-medium {
  font-size: 1em;
}

.tag-cloud .tag-large {
  font-size: 1.2em;
}

.archive-list,
.archives {
  list-style: none;
  padding: 0;
}

.archive-list li,
.archive-item {
  padding: 4px 0;
}

.archive-list li a,
.archive-item a {
  font-size: 0.88em;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  transition: color var(--transition);
}

.archive-list li a:hover,
.archive-item a:hover {
  color: var(--text-primary);
}

.archive-list li a .count {
  color: var(--text-muted);
  font-size: 0.85em;
}

.site-runtime {
  font-size: 0.85em;
  color: var(--text-muted);
  font-family: "SF Mono", "Fira Code", "Courier New", monospace;
  letter-spacing: 0.02em;
}

/* ============================================================
   Page Detail
   ============================================================ */
.page-detail {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 36px;
  border: 1px solid var(--border-light);
}

.page-detail .page-header {
  margin-bottom: 24px;
}

.page-content {
  line-height: 1.8;
  font-size: 1.05em;
  color: var(--text-primary);
  word-break: break-word;
}

.page-content h1,
.page-content h2,
.page-content h3,
.page-content h4,
.page-content h5,
.page-content h6 {
  margin-top: 1.5em;
  margin-bottom: 0.6em;
  font-weight: 600;
  color: var(--text-primary);
}

.page-content p {
  margin-bottom: 1em;
}

.page-content a {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.page-content img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 16px 0;
}

.page-content pre {
  background-color: #1c1e22;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.9em;
  line-height: 1.6;
  margin: 16px 0;
}

.page-content code {
  font-family: "SF Mono", "Fira Code", "Courier New", monospace;
  font-size: 0.9em;
}

.page-content :not(pre) > code {
  background-color: var(--accent-subtle);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--accent-hover);
}

.page-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  color: var(--text-secondary);
  margin: 16px 0;
  background-color: var(--accent-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ============================================================
   Archive Timeline
   ============================================================ */
.archive-page {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 36px;
  border: 1px solid var(--border-light);
}

.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background-color: var(--border);
  border-radius: 1px;
}

.timeline-item {
  position: relative;
  padding: 12px 0 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 2px solid var(--accent);
  z-index: 1;
  transition: background-color var(--transition);
}

.timeline-item:hover .timeline-dot {
  background-color: var(--accent);
}

.timeline-date {
  font-size: 0.85em;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 64px;
  font-family: "SF Mono", "Fira Code", "Courier New", monospace;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.timeline-content {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.timeline-category {
  display: inline-block;
  background-color: var(--accent);
  color: #fff;
  font-size: 0.72em;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.timeline-title {
  font-size: 1em;
  font-weight: 500;
  color: var(--text-primary);
  transition: color var(--transition);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-title:hover {
  color: var(--accent-hover);
}

/* ============================================================
   Error / 404 Page
   ============================================================ */
.error-page {
  text-align: center;
  padding: 80px 20px;
}

.error-page h1 {
  font-size: 6em;
  font-weight: 700;
  color: var(--border);
  line-height: 1;
  margin-bottom: 16px;
  letter-spacing: -0.03em;
}

.error-page p {
  color: var(--text-muted);
  font-size: 1em;
  margin-bottom: 8px;
}

.error-page a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.error-page a:hover {
  color: var(--text-primary);
}

/* ============================================================
   15. Site Footer
   ============================================================ */
.site-footer {
  background-color: var(--bg-footer);
  color: var(--text-inverse);
  padding: 30px 20px;
  text-align: center;
  font-size: 0.88em;
  line-height: 1.8;
}

.site-footer a {
  color: var(--text-inverse);
  opacity: 0.7;
  transition: opacity var(--transition);
}

.site-footer a:hover {
  opacity: 1;
}

.site-footer .footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 16px;
}

.footer-links-label {
  color: var(--text-inverse);
  opacity: 0.5;
  font-size: 0.88em;
}

.site-footer .footer-links a {
  color: var(--text-inverse);
  font-size: 0.92em;
}

.site-footer .footer-links a:hover {
  opacity: 1;
}

.site-footer .footer-copyright,
.site-footer .footer-info {
  opacity: 0.5;
  font-size: 0.82em;
}

.site-footer .footer-powered {
  opacity: 0.4;
  font-size: 0.8em;
  margin-top: 4px;
}

.site-footer .footer-icp {
  margin-top: 8px;
  font-size: 0.82em;
  opacity: 0.5;
}

.site-footer .footer-icp a {
  color: var(--text-inverse);
  text-decoration: none;
}

.site-footer .footer-icp a:hover {
  text-decoration: underline;
  opacity: 1;
}

/* ============================================================
   16. Responsive - Tablet / Mobile (< 768px)
   ============================================================ */
@media (max-width: 768px) {
  .main-container {
    flex-direction: column;
    margin-top: 70px;
    padding: 12px;
    gap: 20px;
  }

  .sidebar {
    width: 100%;
  }

  .hamburger {
    display: flex;
  }

  .header-search {
    display: none;
  }

  .site-nav {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--bg-header);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-light);
    padding: 16px;
    flex-direction: column;
    gap: 8px;
    display: none;
  }

  .site-nav.active {
    display: flex;
  }

  .site-nav a {
    display: block;
    padding: 10px 16px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: background-color var(--transition);
  }

  .site-nav a.active::after {
    display: none;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .gallery-image-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* Article list: switch to vertical on mobile */
  .article-item {
    flex-direction: column;
    padding: 10px;
    gap: 10px;
  }

  .article-cover {
    width: 100%;
  }

  .article-cover img {
    min-height: 180px;
    max-height: 220px;
  }

  .article-header-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .meta-left {
    gap: 10px;
  }

  .article-detail {
    padding: 20px;
  }

  .comment-form .form-row,
  .comment-form-row {
    flex-direction: column;
    gap: 10px;
  }

  /* 手机端评论区：压缩内边距、头像与缩进，避免左侧竖线区域挤占正文空间 */
  .comment-item {
    padding: 12px;
    gap: 10px;
  }

  .comment-avatar img {
    width: 32px;
    height: 32px;
  }

  /* 子回复：头像更小、缩进更浅 */
  .comment-children .comment-avatar img {
    width: 28px;
    height: 28px;
  }

  .comment-children {
    margin-left: 0;
    margin-top: 10px;
    padding-left: 10px;
  }

  /* 昵称 + 回复对象 + 时间在窄屏允许换行，避免横向溢出 */
  .comment-meta {
    flex-wrap: wrap;
    gap: 4px 8px;
  }

  .comment-actions {
    flex-wrap: wrap;
  }

  .comment-content img {
    max-width: 100%;
    height: auto;
  }

  .article-detail .article-header .article-title {
    font-size: 1.5em;
  }
}

/* ============================================================
   17. Responsive - Small Mobile (< 480px)
   ============================================================ */
@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .gallery-image-grid {
    grid-template-columns: 1fr;
  }

  .article-title {
    font-size: 1.2em;
  }

  .article-detail .article-header .article-title {
    font-size: 1.3em;
  }

  .article-body {
    padding: 14px;
  }

  /* 超小屏评论区：进一步压缩头像与缩进；保留 2px 细线维持层级感 */
  .comment-item {
    padding: 10px;
    gap: 8px;
  }

  .comment-avatar img {
    width: 28px;
    height: 28px;
  }

  .comment-children .comment-avatar img {
    width: 24px;
    height: 24px;
  }

  .comment-children {
    padding-left: 6px;
    border-left-width: 1px;
  }

  .comment-content pre {
    font-size: 0.85em;
    padding: 6px 8px;
  }

  .pagination a,
  .pagination span,
  .pagination-link {
    min-width: 30px;
    height: 30px;
    font-size: 0.8em;
  }

  .site-footer {
    padding: 20px 15px;
  }

  .site-footer .footer-links {
    gap: 12px;
  }
}

/* ============================================================
   Mermaid 图表
   ============================================================ */
.mermaid {
  margin: 20px 0;
  text-align: center;
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 24px 32px;
  overflow: visible;
}

.mermaid svg {
  max-width: 100%;
  height: auto;
  overflow: visible !important;
}

/* mermaid 图表：可点击放大 */
.mermaid-clickable {
  cursor: zoom-in;
  position: relative;
  transition: box-shadow 0.2s ease;
}

.mermaid-clickable:hover {
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.35);
}

/* mermaid 图表全屏查看器 */
.mermaid-viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: rgba(17, 24, 39, 0.92);
  display: flex;
  flex-direction: column;
}

.mermaid-viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  color: #fff;
  flex-shrink: 0;
}

.mermaid-viewer-title {
  flex: 1;
  font-size: 13px;
  opacity: 0.65;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mermaid-viewer-btn {
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
}

.mermaid-viewer-btn:hover {
  background-color: rgba(255, 255, 255, 0.22);
}

.mermaid-viewer-stage {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: grab;
  touch-action: none;
}

.mermaid-viewer-stage.dragging {
  cursor: grabbing;
}

.mermaid-viewer-inner {
  will-change: transform;
  background-color: #ffffff;
  border-radius: 10px;
  padding: 20px 28px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

.mermaid-viewer-inner svg {
  max-width: none;
  height: auto;
  display: block;
  overflow: visible !important;
}

/* mermaid 渲染失败时的降级代码块样式 */
.mermaid-fallback {
  margin: 12px 0;
  padding: 12px 16px;
  background-color: var(--bg-card);
  border: 1px dashed var(--border-color, #d1d5db);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary, #6b7280);
  text-align: left;
}

/* ============================================================
   Toast Notification
   ============================================================ */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: var(--text-primary);
  color: var(--bg-card);
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 0.9em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
}

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

/* ============================================================
   Scrollbar Styling
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
  .site-header,
  .sidebar,
  .site-footer,
  .comment-form,
  .comment-form-wrap,
  .pagination,
  .hamburger,
  .toc-float {
    display: none;
  }

  .main-container {
    display: block;
    margin: 0;
    padding: 0;
  }

  .content-area {
    max-width: 100%;
  }
}

/* ============================================================
   Article TOC Float (悬浮目录)
   ============================================================ */
.toc-float {
  position: fixed;
  left: 20px;
  top: 80px;
  width: 220px;
  max-height: calc(100vh - 120px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  z-index: 100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: move;
  transition: box-shadow 0.2s;
}

.toc-float:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.toc-float-header {
  padding: 10px 12px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.toc-float-title {
  font-size: 0.9em;
  font-weight: 600;
  color: var(--text-primary);
}

.toc-float-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  line-height: 1;
}

.toc-float-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.toc-float-reset {
  font-size: 0.8em;
  color: var(--accent);
  cursor: pointer;
  margin-left: 8px;
  text-decoration: none;
}

.toc-float-reset:hover {
  text-decoration: underline;
}

.toc-float-body {
  padding: 10px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

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

.toc-float-item {
  padding: 4px 12px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-float-item a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85em;
  cursor: pointer;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.2s, padding-left 0.2s;
}

.toc-float-item a:hover {
  color: var(--accent);
  padding-left: 4px;
}

.toc-float-item.level-2 {
  padding-left: 24px;
}

.toc-float-item.level-3 {
  padding-left: 36px;
}

.toc-float-item.level-4 {
  padding-left: 48px;
}

/* 移动端点击展开按钮 */
.toc-float-toggle {
  position: fixed;
  left: 12px;
  top: 80px;
  width: 40px;
  height: 40px;
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  z-index: 100;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.toc-float-toggle:hover {
  color: var(--accent);
  border-color: var(--border);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12);
}

/* 给标题添加滚动边距，避开 fixed header */
.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
  scroll-margin-top: 80px;
}

/* ============================================================
   Responsive - TOC Float
   ============================================================ */
@media (max-width: 1024px) {
  .toc-float {
    width: 200px;
    left: 10px;
  }
}

@media (max-width: 768px) {
  .toc-float {
    display: none;
    left: 10px;
    width: calc(100vw - 80px);
    max-height: 60vh;
  }

  .toc-float.visible {
    display: flex;
  }

  .toc-float-toggle {
    display: flex;
  }
}
