:root {
  --bg: #1a1b26;
  --bg-alt: #1f2335;
  --bg-dim: #13141c;
  --fg: #c0caf5;
  --fg-alt: #e6eafd;
  --fg-dim: #7a7b89;
  --accent-red: #ff536d;
  --accent-blue: #7ad2f7;
  --accent-blue-dim: #445a63;
  --accent-green: #c1f885;
  --accent-green-dim: #c0f885ba;
  --accent-orange: #ff9e64;
  --accent-olive: #a3be8c;
  --accent-purple: #b967fc;
}

* { box-sizing: border-box; }
html { min-width: 0; overflow-y: scroll; }
body { min-width: 0; }
body {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  color: var(--fg);
  background: var(--bg);
  font-family: "Maple Mono NF CN";
  font-weight: normal;
  line-height: 1.7;
}
a { color: inherit; }

.sidebar {
  position: sticky;
  top: 0;
  height: calc(100vh - 100px);
  min-width: 0;
  padding: 50px 40px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--bg-alt);
}
.profile { margin-bottom: 3rem; }
.profile__avatar { width: 130px; height: 130px; border: 5px solid var(--fg-alt); border-radius: 50%; }
.profile__name { display: flex; margin-bottom: .5rem; color: var(--fg-alt); font-size: 2rem; letter-spacing: -1px; }
.cursor { display: inline-block; color: var(--accent-blue); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.profile__bio { margin-bottom: 1.5rem; color: var(--fg-dim); font-size: .9rem; line-height: 1.6; }
.profile__socials { display: flex; gap: 1rem; }
.profile__socials a { color: var(--fg-dim); font-size: 1.4rem; text-decoration: none; transition: all .2s; }
.social__btn { padding: 0; color: var(--fg-dim); background: none; border: 0; cursor: pointer; font-size: 1.4rem; line-height: 1; transition: all .2s; }
.profile__socials a:hover, .social__btn:hover, .profile__socials a:focus-visible, .social__btn:focus-visible { color: var(--accent-blue); transform: translateY(-2px); }
.notice { position: fixed; left: 50%; bottom: 30px; z-index: 9999; display: flex; align-items: center; gap: 8px; padding: 12px 24px; color: var(--accent-green); background: var(--bg-alt); border: 1px solid var(--accent-green-dim); border-radius: 50px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); font-size: .9rem; font-weight: bold; opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(100px); transition: all .4s cubic-bezier(.68, -.55, .265, 1.55); }
.notice.active { opacity: 1; transform: translateX(-50%) translateY(0); }
.nav-menu { display: flex; flex-direction: column; gap: .8rem; margin: auto 0; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: var(--fg); border-radius: 8px; text-decoration: none; transition: background .2s, color .2s; }
.nav-item i { font-size: 1.1rem; }
.nav-item:hover, .nav-item:focus-visible { color: var(--fg-alt); background: var(--bg-alt); }
.nav-item:visited { color: var(--fg); }
.nav-item.active { color: var(--accent-blue); }

.main-content { min-width: 0; padding: 60px 80px; }
.content-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3rem; }
.section-title { position: relative; padding-left: 1rem; color: var(--fg-alt); font-size: 1.5rem; }
.section-title::before { content: ""; position: absolute; left: 0; top: 50%; width: 4px; height: 70%; background: var(--accent-blue); border-radius: 2px; transform: translateY(-50%); }
.search-bar { display: flex; align-items: center; padding: 8px 16px; background: var(--bg-alt); border: 1px solid transparent; border-radius: 8px; transition: border-color .3s; }
.search-bar:focus-within { border-color: var(--fg-alt); }
.search-bar input { margin-left: 8px; color: var(--fg); font-family: inherit; background: transparent; border: 0; outline: 0; }
.posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 2rem; }
.post-link { color: var(--fg-alt); text-decoration: none; transition: color .2s; }
.card { display: flex; flex-direction: column; padding: 24px; background: var(--bg-alt); border: 1px solid transparent; border-radius: 12px; transition: transform .3s, border-color .3s, box-shadow .3s; }
.card:hover, .post-link:focus-visible .card { border-color: var(--accent-blue-dim); box-shadow: 0 10px 30px var(--bg-dim); transform: translateY(-5px); }
.card__meta { display: flex; justify-content: space-between; margin-bottom: 1rem; font-size: .85rem; }
.card__date { color: var(--fg-dim); }
.card__tag { color: var(--accent-blue); font-weight: bold; }
.post-link:nth-child(4n + 2) .card__tag { color: var(--accent-purple); }
.post-link:nth-child(4n + 3) .card__tag { color: var(--accent-green); }
.post-link:nth-child(4n + 4) .card__tag { color: var(--accent-orange); }
.card__title { margin-bottom: 1rem; color: var(--fg-alt); font-size: 1.25rem; line-height: 1.4; }
.card__excerpt { flex: 0 0 3.4em; height: 3.4em; margin-bottom: 1.5rem; overflow: hidden; color: var(--fg-dim); font-size: .95rem; line-height: 1.7; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.card__footer { display: flex; align-items: center; justify-content: space-between; padding-top: 1rem; color: var(--fg-dim); font-size: .85rem; border-top: 1px solid rgba(255, 255, 255, .05); }
.card__footer i { margin: 0 5px; }
.read-more { color: var(--accent-blue); opacity: 0; transform: translateX(-10px); transition: all .3s; }
.card:hover .read-more, .post-link:focus-visible .read-more { opacity: 1; transform: translateX(0); }
.empty-state { color: var(--fg-dim); }

.categories-grid, .tags-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2rem; }
.category-link, .tag-link { text-decoration: none; }
.category-card, .tag-card { display: flex; align-items: center; gap: 1.75rem; min-width: 0; padding: 1.25rem 1.5rem; color: var(--fg-alt); background: var(--bg-alt); border: 1px solid transparent; border-radius: 12px; transition: transform .3s, border-color .3s, box-shadow .3s; }
.category-card:hover, .category-link:focus-visible .category-card, .tag-card:hover, .tag-link:focus-visible .tag-card { border-color: var(--accent-blue-dim); box-shadow: 0 10px 30px var(--bg-dim); transform: translateY(-4px); }
.category-card__icon, .tag-card__icon { color: var(--accent-orange); font-size: 1.8rem; }
.category-card__content, .tag-card__content { min-width: 0; flex-grow: 1; }
.category-card__content h3, .tag-card__content h3 { margin: 0; overflow-wrap: anywhere; font-size: 1.05rem; }
.category-card__content span, .tag-card__content span { color: var(--fg-dim); font-size: .85rem; }
.category-card__arrow, .tag-card__arrow { color: var(--accent-blue); }

/* Article typography follows old-blog/frontend/css/article.css. */
.article-page { width: 100%; max-width: 100ch; margin: 0 auto; padding: 2rem 1rem; }
.article-header { color: var(--fg-alt); text-align: center; }
.article-header h1 { font-size: 30px; }
.meta-container { display: flex; align-items: center; justify-content: center; gap: 24px; margin-top: 10px; color: var(--fg-dim); }
.meta-container > span > i { margin: 0 5px; font-size: 1.2rem; }
.meta-container .category { color: var(--accent-orange); text-decoration: none; transition: transform .2s ease-out; }
.meta-container .category:hover { cursor: pointer; transform: scale(1.05); }
.tags { display: flex; align-items: center; justify-content: center; gap: 15px; }
.meta-container .tag { display: flex; color: var(--accent-blue); font-size: .9em; font-weight: bold; text-decoration: none; transition: transform .2s ease-out; }
.meta-container .tag:nth-child(4n + 2) { color: var(--accent-purple); }
.meta-container .tag:nth-child(4n + 3) { color: var(--accent-green); }
.meta-container .tag:nth-child(4n + 4) { color: var(--accent-orange); }
.meta-container .tag::before { content: "#"; }
.meta-container .tag:hover { cursor: pointer; filter: brightness(1.2); transform: scale(1.05); }
.article-body { min-width: 0; }
.article-body p { margin: 1rem 0; }
.article-body strong { color: var(--accent-blue); }
.article-body h2, .article-body h3, .article-body h4 { margin-top: 2rem; color: var(--accent-red); font-weight: bold; }
.article-body ul, .article-body ol { margin-left: 1.5rem; }
.article-body ol li::marker { content: "(" counter(list-item) ") "; }
.article-body li { padding: .7rem 0; }
.article-body a { color: var(--accent-blue); text-decoration: underline; }
.article-body a:visited { color: var(--accent-purple); }
.article-body a:hover, .article-body a:focus { text-decoration: none; filter: brightness(1.05); outline: none; }
.article-body code { font-family: "Maple Mono NF CN"; }
.equation { display: inline-flex; align-items: center; padding: 0; vertical-align: middle; line-height: 1; }
.equation--block { display: block; max-width: 100%; overflow-x: auto; text-align: center; }
.equation svg { display: block; width: auto; max-width: 100%; height: auto; font-size: 1em; }
.equation--block svg { width: 100%; max-width: 100%; height: auto; font-size: 1.2em; }
.equation svg *, .equation--block svg * { fill: currentColor; stroke: currentColor; stroke-width: .6px; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
/* Typst frames are compiled SVG; retain inline positioning and parent color. */
.typst-frame { max-width: 100%; height: auto; color: inherit; vertical-align: middle; }
.typst-frame [fill="#000000"] { fill: currentColor; }
.typst-frame [stroke="#000000"] { stroke: currentColor; }
.cetz-diagram { display: flex; align-items: center; justify-content: center; width: 100%; max-width: 100%; min-width: 0; margin: 1rem auto; overflow-x: auto; overflow-y: hidden; text-align: center; }
.cetz-diagram svg { max-width: 100%; height: auto; }
.cetz-diagram svg * { vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.cetz-diagram svg, .wrap-content__fixed svg { color: inherit; }
.cetz-diagram svg [fill="#000000"], .wrap-content__fixed svg [fill="#000000"] { fill: currentColor; }
.cetz-diagram svg [stroke="#000000"], .wrap-content__fixed svg [stroke="#000000"] { stroke: currentColor; }
.wrap-content { display: grid; grid-template-columns: minmax(0, 45%) minmax(0, 1fr); align-items: stretch; gap: 1em; width: 100%; min-width: 0; margin: 1rem 0; overflow: hidden; }
.wrap-content__fixed { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; overflow: hidden; }
.wrap-content__fixed img, .wrap-content__fixed svg { display: block; width: 100% !important; height: 100% !important; max-width: 100%; max-height: 100%; object-fit: contain; }
.wrap-content__body { min-width: 0; }
.vertical-space { display: block; width: 100%; padding: 0; margin: 0; }
.theorion { min-width: 0; margin-top: 2rem; margin-bottom: 2rem; }
.theorion .theorion__title { margin: 0 0 .5rem; font-weight: 700; }
.theorion .theorion__body { margin: 0; }
.theorion--definition { color: var(--accent-red); }
.theorion--theorem { color: var(--accent-blue); }
.theorion--proposition, .theorion--corollary { color: var(--accent-green); }
.theorion--lemma { color: var(--accent-green-dim); }
.theorion--example { color: var(--accent-olive); }
.theorion--problem, .theorion--exercise { color: var(--accent-orange); }
.theorion--tip { color: var(--accent-green); }
.theorion--note { color: var(--accent-blue); }
.theorion--proof { position: relative; color: var(--fg); }
.theorion--proof::after { content: ""; position: absolute; right: 0; bottom: 0; width: .8em; height: .8em; background: currentColor; border-radius: 2px; }

@media (max-width: 900px) {
  body { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; padding: 40px 20px; border-right: 0; border-bottom: 1px solid var(--bg-alt); }
  .main-content { padding: 40px 20px; }
  .content-header { align-items: stretch; flex-direction: column; gap: 1rem; }
  .search-bar { width: 100%; }
  .posts-grid { grid-template-columns: 1fr; }
  .article-header { text-align: left; }
  .meta-container { justify-content: flex-start; gap: .75rem 3rem; }
}
