/* ==========================================================================
   Modern Minimalist Dual-Column Technical Blog Design System
   Inspired by immarcus.com
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "JetBrains Mono", monospace;
  
  /* Light Theme */
  --bg-main: #ffffff;
  --bg-sidebar: #fafafa;
  --bg-card: #ffffff;
  --bg-hover: #f3f4f6;
  --bg-active: #e5e7eb;
  --bg-code: #f8fafc;
  --bg-code-header: #f1f5f9;
  --border-code: #e2e8f0;
  --bg-quote: #f8fafc;
  --bg-modal: rgba(0, 0, 0, 0.5);

  --text-main: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --text-title: #0f172a;
  
  --border-color: #e5e7eb;
  --border-light: #f3f4f6;
  
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --primary-hover: #1d4ed8;
  --accent: #0ea5e9;

  --sidebar-width: 280px;
  --header-height: 56px;
  --content-max-width: 820px;
  /* 首页卡片网格独立宽度：宽屏下尽量铺满内容区，避免两侧大片留白 */
  --home-content-max-width: 1200px;
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-main: #121214;
  --bg-sidebar: #18181b;
  --bg-card: #18181b;
  --bg-hover: #27272a;
  --bg-active: #3f3f46;
  --bg-code: #18181b;
  --bg-code-header: #121214;
  --border-code: #27272a;
  --bg-quote: #1c1c20;
  --bg-modal: rgba(0, 0, 0, 0.75);

  --text-main: #e4e4e7;
  --text-muted: #a1a1aa;
  --text-light: #71717a;
  --text-title: #f4f4f5;
  
  --border-color: #27272a;
  --border-light: #1f1f23;
  
  --primary: #38bdf8;
  --primary-light: rgba(56, 189, 248, 0.1);
  --primary-hover: #0ea5e9;
  --accent: #38bdf8;
}

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

html {
  font-size: 15px;
  line-height: 1.6;
  font-family: var(--font-sans);
  color: var(--text-main);
  background-color: var(--bg-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow: hidden; /* 彻底锁定全局，由左右子栏各自独立滚动 */
}

body {
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
  overflow: hidden;
  position: relative;
  width: 100%;
}

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

button, input {
  font-family: inherit;
  font-size: inherit;
}

/* ==========================================================================
   Header (Fixed Top Navigation)
   ========================================================================== */
.site-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-main);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background-color: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

[data-theme="dark"] .site-header {
  background-color: rgba(18, 18, 20, 0.92);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-title);
  letter-spacing: -0.02em;
}

.site-logo svg {
  width: 22px;
  height: 22px;
  color: var(--primary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
  list-style: none;
  font-size: 0.95rem;
}

.nav-links a {
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text-title);
  background-color: var(--bg-hover);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  transition: var(--transition);
}

.icon-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-title);
  border-color: var(--text-muted);
}

.sidebar-toggle-btn {
  display: none;
}

/* ==========================================================================
   Main Dual-Column Layout (Independent Scroll for Left & Right)
   ========================================================================== */
.main-wrapper {
  display: flex;
  flex: 1;
  margin-top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* Left Sidebar (Article Index Tree - Independent Scroll) */
.article-sidebar {
  width: var(--sidebar-width);
  border-right: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain; /* 阻止滚动向外冒泡 */
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
}

/* Custom Slim Scrollbars for Independent Panes */
.article-sidebar::-webkit-scrollbar, .article-main::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.article-sidebar::-webkit-scrollbar-thumb, .article-main::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
.article-sidebar::-webkit-scrollbar-thumb:hover, .article-main::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}
.article-sidebar::-webkit-scrollbar-track, .article-main::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-title);
  letter-spacing: -0.01em;
}

.sidebar-count {
  font-size: 0.8rem;
  color: var(--text-light);
  background: var(--bg-hover);
  padding: 2px 8px;
  border-radius: 12px;
}

.sidebar-search-box {
  position: relative;
}

.sidebar-search-input {
  width: 100%;
  padding: 6px 10px 6px 30px;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.sidebar-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.sidebar-search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

/* Year Tree in Sidebar */
.year-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.year-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-title);
  margin-top: 10px;
  margin-bottom: 4px;
  padding-left: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.year-count {
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--text-light);
}

.post-tree-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.post-tree-item a {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.4;
  word-break: break-word;
  transition: var(--transition);
  position: relative;
}

.post-tree-item a:hover {
  background-color: var(--bg-hover);
  color: var(--text-title);
}

.post-tree-item.active a {
  background-color: var(--bg-active);
  color: var(--text-title);
  font-weight: 600;
}

.post-tree-item.active a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background-color: var(--primary);
  border-radius: 2px;
}

.post-tree-item .post-tree-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 2px;
}

.top-badge {
  font-size: 0.7rem;
  background-color: #ef4444;
  color: #fff;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}

/* ==========================================================================
   Right Content Area (Article Reading View)
   ========================================================================== */
.article-main {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  padding: 40px 48px 24px;
  display: flex;
  justify-content: center;
}

.article-container {
  width: 100%;
  max-width: var(--content-max-width);
}

/* Article Header */
.article-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.article-tags-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tag-badge {
  background-color: var(--bg-hover);
  color: var(--text-muted);
  padding: 2px 10px;
  border-radius: 14px;
  font-size: 0.8rem;
  transition: var(--transition);
}

.tag-badge:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

.category-badge {
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 2px 10px;
  border-radius: 14px;
  font-size: 0.8rem;
  font-weight: 600;
}

.article-title {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text-title);
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.article-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Article Body Typography (Subtle & Clean) */
.article-body {
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text-main);
}

.article-body p {
  margin-bottom: 1.5em;
  word-break: break-word;
}

.article-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-title);
  margin-top: 2.2em;
  margin-bottom: 0.8em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

.article-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-title);
  margin-top: 1.8em;
  margin-bottom: 0.6em;
}

.article-body ul, .article-body ol {
  margin-bottom: 1.5em;
  padding-left: 1.8em;
}

.article-body li {
  margin-bottom: 0.5em;
}

.article-body a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

/* Blockquote & Note Callouts */
.article-body blockquote {
  margin: 1.8em 0;
  padding: 12px 18px;
  background-color: var(--bg-quote);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-muted);
  font-size: 0.98rem;
}

.article-body blockquote p:last-child {
  margin-bottom: 0;
}

.callout-alert {
  margin: 1.8em 0;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background-color: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #dc2626;
  font-size: 0.95rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* Images & Zoom */
.article-body img.zoomable-img,
.article-body img:not(.filetype-icon):not([src*="filetype"]):not([src*="icon_"]) {
  max-width: 100% !important;
  height: auto !important;
  border-radius: var(--radius-md);
  margin: 1.5em auto;
  display: block;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  cursor: zoom-in;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  object-fit: contain;
}

/* Inline Attachment & Filetype Icons (Always Left-Aligned with Link, Crisp VS Code Vectors) */
.article-body .filetype-icon,
.article-body img[src*="filetype"],
.article-body img[src*="icon_"],
.article-body .ue-upload img {
  display: inline-block !important;
  vertical-align: -3px !important;
  margin: 0 6px 0 0 !important;
  width: 18px !important;
  height: 18px !important;
  max-width: 18px !important;
  max-height: 18px !important;
  box-shadow: none !important;
  border: none !important;
  border-radius: 0 !important;
  cursor: default !important;
  flex-shrink: 0 !important;
}

.article-body .ue-upload {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  margin: 0.6em 0 !important;
  line-height: normal !important;
}

/* Prevent any wide tables, pre, or elements from overflowing on mobile */
.article-body table {
  max-width: 100% !important;
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1.5em 0;
}

.article-body table td, .article-body table th {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
}

.article-body * {
  max-width: 100% !important;
  box-sizing: border-box !important;
  word-wrap: break-word !important;
  word-break: break-word !important;
}

.article-body img:hover {
  box-shadow: var(--shadow-md);
}

/* Code Highlighting Blocks (Mac style - Crisp Light Theme) */
.code-block-wrapper {
  margin: 1.8em 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: var(--radius-md);
  background-color: var(--bg-code);
  border: 1px solid var(--border-code);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: block;
  clear: both;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 14px;
  background-color: var(--bg-code-header);
  border-bottom: 1px solid var(--border-code);
}

.mac-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mac-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.mac-dots i:nth-child(1) { background-color: #ff5f56; }
.mac-dots i:nth-child(2) { background-color: #ffbd2e; }
.mac-dots i:nth-child(3) { background-color: #27c93f; }

.code-lang {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.copy-code-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 3px 10px;
  cursor: pointer;
  transition: var(--transition);
}

.copy-code-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.article-body pre {
  margin: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 16px 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background-color: transparent !important;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-main);
}

.article-body pre code {
  display: inline-block;
  min-width: 100%;
  padding: 0 !important;
  background: transparent !important;
  font-family: var(--font-mono);
  color: inherit;
}

.article-body code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 6px;
  background-color: var(--bg-hover);
  color: var(--primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

/* Article Navigation (Prev / Next) */
.article-footer-nav {
  margin-top: 48px;
  margin-bottom: 0;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}

.nav-card {
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  text-decoration: none;
  background-color: var(--bg-card);
  overflow: hidden;
}

.nav-card.prev-card {
  text-align: left;
  align-items: flex-start;
}

.nav-card.next-card {
  text-align: right;
  align-items: flex-end;
}

.nav-card:hover {
  border-color: var(--primary);
  background-color: var(--bg-hover);
  box-shadow: var(--shadow-sm);
}

.nav-card .nav-label {
  font-size: 0.78rem;
  color: var(--text-light);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.nav-card .nav-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.nav-card-placeholder {
  min-width: 0;
  visibility: hidden;
}

/* Article Site Footer (Branded, Semantic & Natural Spacing) */
.article-site-footer {
  margin-top: 56px;
  padding: 28px 0 48px;
  border-top: 1px dashed var(--border-color);
  text-align: center;
  color: var(--text-light);
  font-size: 0.82rem;
  line-height: 1.6;
}

.article-site-footer .footer-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.article-site-footer .footer-meta a {
  color: var(--text-light);
  text-decoration: none;
  transition: var(--transition);
}

.article-site-footer .footer-meta a:hover {
  color: var(--primary);
}

.article-site-footer .footer-quote {
  margin-top: 6px;
  font-size: 0.76rem;
  color: var(--text-light);
  opacity: 0.85;
}

/* ==========================================================================
   Search Modal
   ========================================================================== */
.search-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: var(--bg-modal);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

.search-modal-backdrop.open {
  display: flex;
}

.search-dialog {
  width: 100%;
  max-width: 600px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
}

.search-input-wrapper input {
  flex: 1;
  border: none;
  background: none;
  font-size: 1.1rem;
  color: var(--text-main);
  outline: none;
}

.search-results-list {
  max-height: 400px;
  overflow-y: auto;
  list-style: none;
  padding: 8px 0;
}

.search-result-item a {
  display: block;
  padding: 10px 18px;
  transition: var(--transition);
}

.search-result-item a:hover {
  background-color: var(--bg-hover);
}

.search-result-item h4 {
  font-size: 0.95rem;
  color: var(--text-title);
  margin-bottom: 4px;
}

.search-result-item p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

mark {
  background-color: rgba(253, 224, 71, 0.4);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

/* Lightbox Modal */
.lightbox-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.88);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.lightbox-modal.open {
  display: flex;
}

.lightbox-modal img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  object-fit: contain;
}

/* ==========================================================================
   Home Card Grid (标题区 / Hero + 2x2 / 标签分类区 / 双列文章卡片)
   ========================================================================== */
.home-grid {
  width: 100%;
  max-width: var(--home-content-max-width);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* 标题区 */
.home-site-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-title);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.home-site-subtitle {
  margin-top: 8px;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.home-site-stats {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text-light);
}

.home-site-stats .dot {
  color: var(--border-color);
}

.home-filter-clear {
  margin-left: 8px;
  color: var(--primary);
  text-decoration: none;
}

.home-filter-clear:hover {
  text-decoration: underline;
}

/* 顶部分享区：Hero 主卡 + 2x2 推荐卡 */
.home-top {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 12px;
  align-items: stretch;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 1fr;
  gap: 10px;
}

/* 卡片通用外观 */
.hero-card,
.feature-card,
.post-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: var(--transition);
}

.hero-card:hover,
.feature-card:hover,
.post-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.hero-card {
  justify-content: center;
  gap: 8px;
  padding: 18px 22px;
  background-image: linear-gradient(135deg, var(--primary-light), var(--bg-card) 60%);
}

.feature-card {
  gap: 4px;
  padding: 12px 14px;
}

/* 卡片头部：分类 / 置顶 / 日期 */
.home-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.card-cat {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  background-color: var(--primary-light);
  padding: 2px 8px;
  border-radius: 10px;
}

.card-pin,
.card-latest {
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  padding: 2px 7px;
  border-radius: 10px;
}

.card-pin {
  background-color: #ef4444;
}

.card-latest {
  background-color: #10b981;
}

.card-date {
  margin-left: auto;
  font-size: 0.76rem;
  color: var(--text-light);
}

.card-lock {
  margin-right: 4px;
  font-size: 0.85rem;
}

/* 卡片标题与摘要 */
.hero-card-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-title);
  line-height: 1.32;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-card-excerpt {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feature-card-title,
.post-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-title);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feature-card-title {
  font-size: 0.95rem;
}

.feature-card-excerpt,
.post-card-excerpt {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feature-card-excerpt {
  font-size: 0.78rem;
  -webkit-line-clamp: 1;
}

/* 卡片标签与统计 */
.home-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.card-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  background-color: var(--bg-hover);
  padding: 2px 7px;
  border-radius: 10px;
}

.home-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 8px;
  font-size: 0.76rem;
  color: var(--text-light);
}

/* Hero 内统计紧跟内容，避免卡片被拉伸后出现大片空白 */
.hero-card .home-card-meta {
  margin-top: 8px;
}

.card-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* 标签 / 分类筛选区 */
.home-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.filter-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.filter-label {
  flex-shrink: 0;
  min-width: 32px;
  padding-top: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  font-size: 0.78rem;
  color: var(--text-muted);
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 4px 12px;
  border-radius: 14px;
  text-decoration: none;
  transition: var(--transition);
}

.filter-chip:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.filter-chip.active {
  color: #fff;
  background-color: var(--primary);
  border-color: var(--primary);
}

/* 双列最新发布 */
.home-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.home-section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-title);
}

.home-section-count {
  font-size: 0.8rem;
  color: var(--text-light);
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.post-card {
  gap: 8px;
}

.post-card-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
  font-size: 0.76rem;
  color: var(--text-light);
}

.home-empty {
  padding: 40px 0;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-light);
}

/* ==========================================================================
   Responsive Adaptations & Mobile Drawer Overlay
   ========================================================================== */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--bg-modal);
  backdrop-filter: blur(2px);
  z-index: 80;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 300px;
    --header-height: 52px;
  }

  .site-header {
    padding: 0 12px;
  }

  .site-logo span {
    font-size: 1rem;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 手机端隐藏顶栏过长的水平菜单，放入侧边栏或汉堡菜单 */
  .nav-links {
    display: none !important;
  }

  .sidebar-toggle-btn {
    display: flex;
    padding: 6px;
  }

  .header-right {
    gap: 6px;
  }

  .header-right .icon-btn span {
    display: none; /* 手机端只显示搜索图标，不显示文字 */
  }

  .main-wrapper {
    position: relative;
  }

  /* 抽屉式侧边栏 */
  .article-sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    width: min(320px, 85vw);
    z-index: 90;
    transform: translateX(-100%);
    box-shadow: none;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.28s;
    background-color: var(--bg-sidebar);
  }

  .article-sidebar.drawer-open {
    transform: translateX(0);
    box-shadow: 6px 0 25px rgba(0, 0, 0, 0.18);
    visibility: visible;
    pointer-events: auto;
  }

  /* 手机端沉浸阅读正文排版 */
  .article-main {
    padding: 20px 16px 0;
    overflow-x: hidden;
  }

  .article-title {
    font-size: 1.45rem;
    line-height: 1.35;
    margin-bottom: 12px;
  }

  .article-meta {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.8rem;
  }

  .article-body {
    font-size: 0.98rem;
    line-height: 1.75;
  }

  .article-body h2 {
    font-size: 1.3rem;
    margin-top: 1.6em;
  }

  .article-body h3 {
    font-size: 1.15rem;
    margin-top: 1.4em;
  }

  .article-body img {
    margin: 1em auto;
    border-radius: var(--radius-sm);
  }

  .code-block-wrapper {
    margin: 1.4em 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: var(--radius-sm);
  }

  .article-body pre {
    padding: 12px 14px;
    font-size: 0.84rem;
  }

  .article-footer-nav {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 32px;
    margin-bottom: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .nav-card-placeholder {
    display: none;
  }

  .nav-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .article-site-footer {
    margin-top: 40px;
    padding: 24px 0 44px;
    font-size: 0.78rem;
  }
}

.friend-link-item {
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s ease;
  padding: 2px 4px;
  border-radius: 4px;
}

.friend-link-item:hover {
  color: var(--primary) !important;
  background-color: var(--bg-hover);
  text-decoration: none;
}

/* ==========================================================================
   Home Card Grid — Mobile Adaptations
   ========================================================================== */
@media (max-width: 900px) {
  .home-top {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .home-grid {
    gap: 20px;
  }

  .home-site-title {
    font-size: 1.55rem;
  }

  .home-site-subtitle {
    font-size: 0.86rem;
  }

  .hero-card {
    padding: 20px;
  }

  .hero-card-title {
    font-size: 1.25rem;
  }

  .hero-card-excerpt {
    font-size: 0.86rem;
  }

  .feature-card {
    padding: 14px;
  }

  .post-grid {
    grid-template-columns: 1fr;
  }

  .home-filters {
    padding: 14px 16px;
  }

  .filter-row {
    flex-direction: column;
    gap: 8px;
  }

  .filter-label {
    padding-top: 0;
  }

  .filter-chips {
    gap: 6px;
  }
}

@media (max-width: 560px) {
  .feature-grid {
    grid-template-columns: 1fr;
  }
}
