/* Mossvale Notes — Editorial Chinese CS & AI Study Blog */
:root {
  --bg: #faf9f5;
  --bg-elevated: #ffffff;
  --bg-subtle: #f2efe9;
  --bg-code: #f4f1ea;
  --text: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #78716c;
  --border: #e7e3da;
  --border-strong: #d6d0c4;
  --accent: #1d4ed8;
  --accent-hover: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.09);
  --accent-warm: #b45309;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-md: 0 8px 24px rgba(28, 25, 23, 0.06);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", Consolas, "Courier New", monospace;
  --max-width: 1040px;
  --article-width: 740px;
}

[data-theme="dark"] {
  --bg: #111315;
  --bg-elevated: #181b1f;
  --bg-subtle: #1e2228;
  --bg-code: #16191e;
  --text: #e7e5e4;
  --text-secondary: #a8a29e;
  --text-muted: #78716c;
  --border: #272c34;
  --border-strong: #373e49;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --accent-warm: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.35);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.75;
  transition: background-color 0.2s ease, color 0.2s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent-hover); }

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

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Reading Progress Bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  z-index: 200;
  transition: width 0.08s linear;
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}
.site-brand:hover { color: var(--accent); }
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
}
[data-theme="dark"] .brand-mark { color: #0b1414; }

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

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.94rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.icon-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--bg-subtle);
}
.icon-btn kbd {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.menu-toggle { display: none; }

/* Main content */
main { flex: 1; padding: 40px 0 72px; }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 36px;
  align-items: center;
  padding: 20px 0 44px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 44px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(1.9rem, 3.2vw, 2.5rem);
  line-height: 1.25;
  letter-spacing: -0.025em;
}
.hero p {
  margin: 0 0 22px;
  color: var(--text-secondary);
  font-size: 1.03rem;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
[data-theme="dark"] .btn-primary { color: #0b1414; }
[data-theme="dark"] .btn-primary:hover { color: #0b1414; }
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-subtle); color: var(--text); }

.hero-visual {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  background: var(--bg-elevated);
}
.hero-visual img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }

/* Section Headers */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 12px;
}
.section-head h2 {
  margin: 0;
  font-size: 1.32rem;
  letter-spacing: -0.015em;
}
.section-head a { font-size: 0.9rem; font-weight: 500; }

/* Featured Cards Grid */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-bottom: 52px;
}
.post-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.post-card-cover {
  display: block;
  overflow: hidden;
  background: var(--bg-subtle);
}
.post-card-cover img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 0.35s ease;
}
.post-card:hover .post-card-cover img { transform: scale(1.03); }
.post-card-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.cat-pill {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}
.post-card h3 {
  margin: 0 0 8px;
  font-size: 1.06rem;
  line-height: 1.42;
}
.post-card h3 a { color: var(--text); }
.post-card h3 a:hover { color: var(--accent); }
.post-card p {
  margin: 0 0 14px;
  font-size: 0.89rem;
  color: var(--text-secondary);
  line-height: 1.65;
  flex: 1;
}

/* Post List */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.post-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 18px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.post-row:hover { border-color: var(--border-strong); }
.post-row-main { flex: 1; min-width: 0; }
.post-row h3 {
  margin: 4px 0 6px;
  font-size: 1.08rem;
  line-height: 1.4;
}
.post-row h3 a { color: var(--text); }
.post-row h3 a:hover { color: var(--accent); }
.post-row p {
  margin: 0 0 10px;
  font-size: 0.91rem;
  color: var(--text-secondary);
}
.post-row-date {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 4px;
}

/* Tag chips */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 2px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tag-chip:hover,
.tag-chip.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Filter Toolbar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.filter-input {
  flex: 1;
  min-width: 220px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
}
.filter-input:focus { outline: none; border-color: var(--accent); }

/* Article Layout */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 40px;
  align-items: start;
}

.article-header {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.article-header h1 {
  margin: 10px 0 14px;
  font-size: clamp(1.65rem, 2.8vw, 2.15rem);
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.article-lead {
  font-size: 1.03rem;
  color: var(--text-secondary);
  margin: 0 0 18px;
}
.article-cover {
  margin: 22px 0 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}
.article-cover img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }

/* Article Prose */
.prose { font-size: 1rem; line-height: 1.85; }
.prose h2 {
  margin: 2.2em 0 0.8em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--border);
  font-size: 1.42rem;
  line-height: 1.35;
  scroll-margin-top: 84px;
}
.prose h3 {
  margin: 1.7em 0 0.6em;
  font-size: 1.15rem;
  line-height: 1.4;
  scroll-margin-top: 84px;
}
.prose p { margin: 0 0 1.15em; }
.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.5em; }
.prose li { margin: 0.35em 0; }
.prose strong { color: var(--text); font-weight: 600; }

.prose code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-code);
  border: 1px solid var(--border);
}

.code-block {
  position: relative;
  margin: 1.3em 0 1.5em;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-code);
  overflow: hidden;
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
}
.copy-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  padding: 2px 9px;
  border-radius: 4px;
  cursor: pointer;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.65;
}
.code-block pre code {
  padding: 0;
  border: none;
  background: transparent;
  font-size: 0.85rem;
}

.callout {
  margin: 1.4em 0;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  font-size: 0.94rem;
}
.callout.warn {
  border-left-color: var(--accent-warm);
  background: color-mix(in srgb, var(--accent-warm) 10%, transparent);
}
.callout-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
  white-space: nowrap;
}
.prose th { background: var(--bg-subtle); font-weight: 600; }

.diagram-figure {
  margin: 1.6em 0;
  padding: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.diagram-figure svg { width: 100%; height: auto; display: block; }
.diagram-figure figcaption {
  margin-top: 10px;
  text-align: center;
  font-size: 0.83rem;
  color: var(--text-muted);
}

/* Sticky TOC */
.toc-aside {
  position: sticky;
  top: 86px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.84rem;
}
.toc-title {
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 10px;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}
.toc-list li { margin: 0; }
.toc-list a {
  display: block;
  padding: 4px 0 4px 12px;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  margin-left: -1px;
  line-height: 1.45;
}
.toc-list a.level-3 { padding-left: 22px; font-size: 0.8rem; }
.toc-list a:hover,
.toc-list a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* Prev / Next Navigation */
.article-nav {
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.article-nav a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text);
}
.article-nav a:hover { border-color: var(--accent); }
.article-nav .nav-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.article-nav .next { text-align: right; }

/* Archive Timeline */
.archive-group { margin-bottom: 34px; }
.archive-group h2 {
  font-size: 1.18rem;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.archive-item {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}
.archive-item time {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.archive-item a { color: var(--text); font-weight: 500; }
.archive-item a:hover { color: var(--accent); }

/* Search Modal */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 16px 24px;
}
.search-modal.open { display: flex; }
.search-box {
  width: 100%;
  max-width: 600px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.search-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}
.search-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 8px;
}
.search-item {
  display: block;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
}
.search-item:hover { background: var(--bg-subtle); }
.search-item-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 3px; }
.search-item-desc { font-size: 0.83rem; color: var(--text-secondary); }
.search-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.footer-links { display: flex; gap: 16px; }
.footer-links a { color: var(--text-secondary); }
.footer-links a:hover { color: var(--accent); }

/* Page title header */
.page-hero {
  margin-bottom: 30px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.page-hero h1 { margin: 0 0 8px; font-size: 1.75rem; }
.page-hero p { margin: 0; color: var(--text-secondary); }

/* About cards */
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin: 24px 0;
}
.info-card {
  padding: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.info-card h3 { margin: 0 0 8px; font-size: 1.02rem; }
.info-card p, .info-card ul { margin: 0; font-size: 0.91rem; color: var(--text-secondary); }
.info-card ul { padding-left: 1.2em; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 24px; }
  .featured-grid { grid-template-columns: repeat(2, 1fr); }
  .article-layout { grid-template-columns: 1fr; }
  .toc-aside { display: none; }
}

@media (max-width: 640px) {
  .featured-grid, .info-grid, .article-nav { grid-template-columns: 1fr; }
  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px 16px;
    flex-direction: column;
    align-items: stretch;
  }
  .nav-links.open { display: flex; }
  .menu-toggle { display: inline-flex; }
  .post-row { flex-direction: column; gap: 6px; }
  .icon-btn kbd { display: none; }
}
