:root {
    color-scheme: light;
    --page-bg: #f5f7fb;
    --surface: #ffffff;
    --surface-subtle: #f8fafc;
    --text: #0f172a;
    --text-soft: #334155;
    --muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --accent: #2563eb;
    --accent-strong: #1d4ed8;
    --accent-soft: #eff6ff;
    --signature: #f59e0b;
    --profile: #071a3c;
    --profile-soft: #0f2a5a;
    --code-bg: #0b1220;
    --code-text: #dbeafe;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.045);
    --shadow-md: 0 16px 44px rgba(15, 23, 42, 0.08);
    --radius: 18px;
    --radius-control: 12px;
    --container: 1180px;
    --sidebar-width: 300px;
    --layout-gap: 28px;
    --page-gutter: 20px;
    --header-height: 68px;
    --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --page-bg: #0b1120;
    --surface: #111827;
    --surface-subtle: #182234;
    --text: #eef2ff;
    --text-soft: #cbd5e1;
    --muted: #94a3b8;
    --border: #263244;
    --border-strong: #3a4960;
    --accent-soft: #142c5e;
    --profile: #071225;
    --profile-soft: #10244a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.18);
    --shadow-md: 0 18px 50px rgba(0, 0, 0, 0.28);
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--page-bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    transition: background-color 180ms ease, color 180ms ease;
}

body.nav-open,
body.search-open {
    overflow: hidden;
}

img,
svg {
    display: block;
    max-width: 100%;
}

button,
input,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

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

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

button {
    color: inherit;
}

.icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    z-index: 1000;
    top: 10px;
    left: 10px;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--text);
    color: var(--surface);
    transform: translateY(-160%);
}

.skip-link:focus {
    transform: translateY(0);
}

:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.32);
    outline-offset: 3px;
}

/* Header */

.site-header {
    position: sticky;
    z-index: 100;
    top: 0;
    min-height: var(--header-height);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px);
}

@supports not (background: color-mix(in srgb, white 50%, transparent)) {
    .site-header {
        background: var(--surface);
    }
}

.header-inner {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) auto minmax(190px, 1fr);
    align-items: center;
    width: min(calc(100% - var(--page-gutter) - var(--page-gutter)), var(--container));
    min-height: var(--header-height);
    margin: 0 auto;
}

.brand {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    gap: 10px;
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.035em;
}

.brand:hover {
    color: var(--text);
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-subtle);
    color: var(--accent);
}

.brand-mark .icon {
    width: 24px;
    height: 24px;
}

.site-nav {
    display: flex;
    align-items: stretch;
    align-self: stretch;
    gap: 34px;
}

.site-nav a {
    position: relative;
    display: inline-flex;
    align-items: center;
    color: var(--text-soft);
    font-size: 15px;
    font-weight: 600;
}

.site-nav a::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--accent);
    content: "";
    opacity: 0;
    transform: scaleX(0.5);
    transition: opacity 160ms ease, transform 160ms ease;
}

.site-nav a:hover,
.site-nav a.is-current {
    color: var(--accent);
}

.site-nav a.is-current::after {
    opacity: 1;
    transform: scaleX(1);
}

.header-actions {
    display: flex;
    justify-self: end;
    gap: 4px;
}

.icon-button {
    display: inline-grid;
    width: 44px;
    height: 44px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease;
}

.icon-button:hover {
    background: var(--surface-subtle);
    color: var(--accent);
}

.icon-button .icon-close,
.icon-button .icon-sun,
.menu-toggle {
    display: none;
}

html[data-theme="dark"] .icon-button .icon-moon {
    display: none;
}

html[data-theme="dark"] .icon-button .icon-sun {
    display: block;
}

.search-open [data-search-toggle] .icon-search {
    display: none;
}

.search-open [data-search-toggle] .icon-close {
    display: block;
}

.search-panel {
    position: absolute;
    top: calc(100% + 1px);
    right: 0;
    left: 0;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.search-panel[hidden] {
    display: none;
}

.search-form {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    width: min(100%, 720px);
    min-height: 52px;
    margin: 0 auto;
    padding-left: 16px;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    background: var(--surface-subtle);
    overflow: hidden;
}

.search-form > .icon {
    color: var(--muted);
}

.search-form input {
    min-width: 0;
    height: 50px;
    padding: 0 14px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
}

.search-form input::placeholder {
    color: var(--muted);
}

.search-form button {
    align-self: stretch;
    min-width: 86px;
    border: 0;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.search-form button:hover {
    background: var(--accent-strong);
}

/* Main layout */

.site-main {
    min-height: calc(100vh - var(--header-height) - 120px);
}

.page-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
    align-items: start;
    gap: var(--layout-gap);
    width: min(calc(100% - var(--page-gutter) - var(--page-gutter)), var(--container));
    margin: 0 auto;
    padding: 42px 0 72px;
}

.content-column {
    min-width: 0;
}

.page-intro {
    margin: 0 0 24px;
}

.page-intro h1 {
    margin: 0;
    color: var(--text);
    font-size: clamp(30px, 4vw, 42px);
    line-height: 1.2;
    letter-spacing: -0.035em;
}

.page-intro p {
    max-width: 700px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 16px;
}

.archive-intro h1 {
    font-size: clamp(28px, 3.2vw, 38px);
}

.post-list {
    display: grid;
    gap: 14px;
}

/* Article cards */

.post-card {
    position: relative;
    display: grid;
    min-height: 186px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.post-card::after {
    position: absolute;
    top: -1px;
    right: -1px;
    width: 22px;
    height: 22px;
    border: solid var(--border);
    border-width: 0 0 1px 1px;
    border-radius: 0 18px 0 8px;
    background: var(--page-bg);
    content: "";
}

.post-card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.09);
    transform: translateY(-2px);
}

.post-card-content {
    display: flex;
    min-width: 0;
    padding: 24px 28px 22px 30px;
    border-left: 4px solid var(--accent);
    flex-direction: column;
}

.post-card-category {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}

.post-card-category .icon {
    width: 16px;
    height: 16px;
}

.post-card-category a {
    color: inherit;
}

.post-card-title {
    margin: 9px 0 8px;
    font-size: clamp(20px, 2vw, 25px);
    line-height: 1.38;
    letter-spacing: -0.02em;
}

.post-card-title a {
    color: var(--text);
    text-decoration: none;
}

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

.post-card-excerpt {
    display: -webkit-box;
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.75;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.post-card-meta {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: auto;
    padding-top: 18px;
    color: var(--muted);
    font-size: 13px;
}

.post-card-meta > span,
.post-card-meta > a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.post-card-meta .icon {
    width: 16px;
    height: 16px;
}

.post-card-read {
    margin-left: auto;
    color: var(--accent);
    font-weight: 700;
}

.post-card-read .icon {
    transition: transform 160ms ease;
}

.post-card-read:hover .icon {
    transform: translateX(3px);
}

/* Sidebar */

.sidebar {
    min-width: 0;
}

.sidebar-sticky {
    position: sticky;
    top: calc(var(--header-height) + 22px);
    display: grid;
    align-content: start;
    gap: 14px;
}

.sidebar-persistent,
.sidebar-toc-shell {
    display: grid;
    min-width: 0;
}

.sidebar-scroll-body {
    display: grid;
    min-width: 0;
    align-content: start;
    gap: 14px;
    grid-auto-rows: max-content;
}

.is-post .sidebar,
.is-page .sidebar {
    align-self: stretch;
}

.is-post .sidebar-sticky,
.is-page .sidebar-sticky {
    position: static;
    min-height: 100%;
}

:is(.is-post, .is-page) .sidebar[data-sidebar-mode="toc"] .sidebar-toc-shell,
:is(.is-post, .is-page) .sidebar[data-sidebar-mode="content"] .sidebar-persistent {
    --sidebar-scroll-rail: 14px;
    position: sticky;
    z-index: 1;
    top: calc(var(--header-height) + 22px);
    width: calc(100% + var(--sidebar-scroll-rail));
    margin-right: calc(var(--sidebar-scroll-rail) * -1);
    background: var(--page-bg);
}

:is(.is-post, .is-page) .sidebar[data-sidebar-mode="toc"] .sidebar-toc-shell::before,
:is(.is-post, .is-page) .sidebar[data-sidebar-mode="content"] .sidebar-persistent::before {
    position: absolute;
    right: 0;
    bottom: 100%;
    left: 0;
    height: 22px;
    background: var(--page-bg);
    content: "";
}

:is(.is-post, .is-page) .sidebar[data-sidebar-mode="toc"] .sidebar-toc-shell > .sidebar-scroll-body,
:is(.is-post, .is-page) .sidebar[data-sidebar-mode="content"] .sidebar-persistent > .sidebar-scroll-body {
    max-height: calc(100vh - var(--header-height) - 44px);
    max-height: calc(100dvh - var(--header-height) - 44px);
    padding-right: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
}

.sidebar-scroll-body::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll-body::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-scroll-body::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted) 45%, transparent);
}

.profile-card,
.sidebar-widget {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.profile-card {
    padding: 30px 24px 24px;
    border-color: rgba(255, 255, 255, 0.08);
    background: var(--profile);
    color: #e8eefb;
    text-align: center;
}

.profile-ears::before,
.profile-ears::after {
    position: absolute;
    top: -1px;
    width: 0;
    height: 0;
    border-right: 16px solid transparent;
    border-bottom: 20px solid var(--profile);
    border-left: 16px solid transparent;
    content: "";
}

.profile-ears::before {
    left: 92px;
}

.profile-ears::after {
    right: 92px;
}

.profile-avatar-wrap {
    width: 92px;
    height: 92px;
    margin: 0 auto 16px;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    background: #fff;
}

.profile-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.profile-card h2 {
    margin: 0;
    color: #fff;
    font-size: 23px;
    line-height: 1.25;
}

.profile-tagline {
    margin: 7px 0 0;
    color: #cbd7ef;
    font-size: 14px;
}

.profile-accent {
    display: block;
    width: 36px;
    height: 4px;
    margin: 15px auto;
    border-radius: 4px;
    background: var(--signature);
}

.profile-bio {
    margin: 0;
    color: #aebbd4;
    font-size: 13px;
    line-height: 1.75;
}

.profile-links {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.profile-links a {
    display: inline-flex;
    min-height: 38px;
    padding: 0 10px;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #dbe7ff;
    font-size: 12px;
    font-weight: 700;
}

.profile-links a:hover {
    border-color: rgba(255, 255, 255, 0.32);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.profile-links .icon {
    width: 17px;
    height: 17px;
}

.sidebar-widget {
    padding: 20px;
}

.widget-title {
    margin: 0 0 14px;
    color: var(--text);
    font-size: 15px;
    line-height: 1.4;
}

.category-list,
.friend-link-list,
.recent-list,
.recent-comment-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.category-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.category-list li {
    min-width: 0;
    --category-color: #2563eb;
}

.category-list li:nth-child(6n + 2) {
    --category-color: #7c3aed;
}

.category-list li:nth-child(6n + 3) {
    --category-color: #d97706;
}

.category-list li:nth-child(6n + 4) {
    --category-color: #059669;
}

.category-list li:nth-child(6n + 5) {
    --category-color: #db2777;
}

.category-list li:nth-child(6n) {
    --category-color: #0891b2;
}

.category-list a {
    display: grid;
    min-height: 68px;
    padding: 10px;
    grid-template-columns: 32px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    border: 1px solid color-mix(in srgb, var(--category-color) 18%, var(--border));
    border-radius: 13px;
    background: color-mix(in srgb, var(--category-color) 7%, var(--surface));
    color: var(--text-soft);
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.category-list a:hover {
    border-color: color-mix(in srgb, var(--category-color) 38%, var(--border));
    color: var(--category-color);
    box-shadow: 0 8px 20px color-mix(in srgb, var(--category-color) 12%, transparent);
    transform: translateY(-2px);
}

.category-icon {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 10px;
    background: color-mix(in srgb, var(--category-color) 13%, var(--surface));
    color: var(--category-color);
}

.category-icon .icon {
    width: 16px;
    height: 16px;
}

.category-copy {
    min-width: 0;
}

.category-name {
    display: block;
    overflow: hidden;
    color: var(--text);
    font-size: 13px;
    font-weight: 750;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-list a:hover .category-name {
    color: var(--category-color);
}

.category-count {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.3;
}

.friend-link-list {
    display: grid;
    gap: 8px;
}

.friend-link-list a {
    display: grid;
    min-height: 50px;
    padding: 8px 9px;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-subtle);
    color: var(--text-soft);
    transition: border-color 160ms ease, background-color 160ms ease;
}

.friend-link-list a:hover {
    border-color: color-mix(in srgb, var(--accent) 36%, var(--border));
    background: var(--accent-soft);
    color: var(--accent);
}

.friend-link-icon {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 10px;
    background: var(--surface);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--border);
}

.friend-link-icon .icon,
.friend-link-arrow {
    width: 16px;
    height: 16px;
}

.friend-link-copy {
    min-width: 0;
}

.friend-link-copy strong,
.friend-link-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friend-link-copy strong {
    color: var(--text);
    font-size: 12px;
    line-height: 1.4;
}

.friend-link-copy small {
    margin-top: 1px;
    color: var(--muted);
    font-size: 10px;
}

.friend-link-arrow {
    color: var(--muted);
    transition: transform 160ms ease;
}

.friend-link-list a:hover .friend-link-arrow {
    transform: translateX(2px);
}

.recent-list {
    counter-reset: recent;
}

.recent-list li {
    position: relative;
    padding: 0 0 13px 20px;
    counter-increment: recent;
}

.recent-list li:last-child {
    padding-bottom: 0;
}

.recent-list li::before {
    position: absolute;
    top: 8px;
    left: 1px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    content: "";
}

.recent-list a {
    display: -webkit-box;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 650;
    line-height: 1.55;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

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

.recent-list time {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.recent-comment-list {
    display: grid;
    gap: 12px;
}

.recent-comment-list li {
    min-width: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.recent-comment-list li:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.recent-comment-link {
    display: block;
    min-width: 0;
    color: var(--text-soft);
}

.recent-comment-meta {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.recent-comment-author {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    font-weight: 750;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-comment-meta time {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.4;
}

.recent-comment-excerpt {
    display: -webkit-box;
    margin-top: 5px;
    overflow: hidden;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.6;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.recent-comment-link:hover .recent-comment-author,
.recent-comment-link:hover .recent-comment-excerpt {
    color: var(--accent);
}

.widget-empty {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.feed-link {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 650;
}

.feed-link > .icon:first-child {
    color: var(--signature);
}

.feed-link > .icon:last-child {
    width: 17px;
    height: 17px;
    color: var(--muted);
}

/* Table of contents */

.sidebar-toc-shell[hidden],
.toc-widget[hidden],
.mobile-toc-panel[hidden],
.mobile-toc-toggle[hidden] {
    display: none;
}

.toc-widget {
    overflow: hidden;
}

.toc-list ol,
.mobile-toc-panel ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

.toc-list li,
.mobile-toc-panel li {
    position: relative;
}

.toc-list a,
.mobile-toc-panel a {
    display: block;
    padding: 7px 0 7px 15px;
    border-left: 2px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.toc-list .toc-level-2 > a,
.mobile-toc-panel .toc-level-2 > a {
    padding-left: 28px;
    font-size: 12px;
}

.toc-list .toc-level-3 > a,
.mobile-toc-panel .toc-level-3 > a {
    padding-left: 40px;
    font-size: 12px;
}

.toc-list a:hover,
.toc-list a.is-active,
.mobile-toc-panel a:hover,
.mobile-toc-panel a.is-active {
    border-left-color: var(--accent);
    color: var(--accent);
}

.mobile-toc-toggle,
.mobile-toc-panel {
    display: none;
}

/* Article */

.post-layout {
    padding-top: 32px;
}

.article-card,
.comments-card,
.post-near {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.article-card {
    position: relative;
    padding: 42px 48px 48px;
    overflow: hidden;
}

.article-card::after {
    position: absolute;
    right: -34px;
    bottom: -34px;
    width: 76px;
    height: 76px;
    border: 8px solid var(--accent);
    transform: rotate(45deg);
    content: "";
    opacity: 0.9;
}

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

.article-header h1 {
    margin: 0;
    color: var(--text);
    font-size: clamp(30px, 4.2vw, 45px);
    line-height: 1.25;
    letter-spacing: -0.035em;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 22px;
    margin-top: 18px;
    color: var(--muted);
    font-size: 13px;
}

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

.article-meta .icon {
    width: 16px;
    height: 16px;
}

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

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

.markdown-body {
    color: var(--text-soft);
    font-size: 17px;
    line-height: 1.9;
    overflow-wrap: break-word;
    word-break: break-word;
}

.markdown-body > :first-child {
    margin-top: 0 !important;
}

.markdown-body > :last-child {
    margin-bottom: 0 !important;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    position: relative;
    margin: 2.1em 0 0.75em;
    scroll-margin-top: calc(var(--header-height) + 24px);
    color: var(--text);
    font-weight: 780;
    line-height: 1.38;
    letter-spacing: -0.018em;
}

.markdown-body h1 {
    font-size: 2em;
}

.markdown-body h2 {
    padding-bottom: 0.38em;
    border-bottom: 1px solid var(--border);
    font-size: 1.55em;
}

.markdown-body h2::before {
    display: inline-block;
    width: 4px;
    height: 0.9em;
    margin-right: 10px;
    border-radius: 4px;
    background: var(--accent);
    content: "";
    vertical-align: -0.05em;
}

.markdown-body h3 {
    font-size: 1.27em;
}

.markdown-body h4 {
    font-size: 1.08em;
}

.heading-anchor {
    position: absolute;
    top: 50%;
    left: -28px;
    display: grid;
    width: 24px;
    height: 28px;
    place-items: center;
    color: var(--muted);
    opacity: 0;
    transform: translateY(-50%);
    transition: opacity 160ms ease;
}

.heading-anchor .icon {
    width: 16px;
    height: 16px;
}

.markdown-body h2:hover .heading-anchor,
.markdown-body h3:hover .heading-anchor,
.markdown-body h4:hover .heading-anchor,
.heading-anchor:focus-visible {
    opacity: 1;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body table,
.markdown-body .table-scroll,
.markdown-body figure,
.markdown-body details {
    margin-top: 1.2em;
    margin-bottom: 1.2em;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.55em;
}

.markdown-body li + li {
    margin-top: 0.35em;
}

.markdown-body li::marker {
    color: var(--accent);
}

.markdown-body a {
    text-decoration: underline;
    text-decoration-color: rgba(37, 99, 235, 0.3);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.markdown-body strong {
    color: var(--text);
    font-weight: 750;
}

.markdown-body em {
    color: var(--text-soft);
}

.markdown-body blockquote {
    padding: 18px 22px;
    border-left: 4px solid var(--accent);
    border-radius: 0 12px 12px 0;
    background: var(--accent-soft);
    color: var(--text-soft);
}

.markdown-body blockquote > :first-child {
    margin-top: 0;
}

.markdown-body blockquote > :last-child {
    margin-bottom: 0;
}

.markdown-body code,
.markdown-body kbd,
.markdown-body pre {
    font-family: var(--font-mono);
}

.markdown-body :not(pre) > code {
    padding: 0.18em 0.42em;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-subtle);
    color: #dc2626;
    font-size: 0.88em;
}

html[data-theme="dark"] .markdown-body :not(pre) > code {
    color: #fda4af;
}

.markdown-body pre {
    position: relative;
    max-width: 100%;
    padding: 22px 24px;
    border: 1px solid #1e293b;
    border-radius: 14px;
    background: var(--code-bg);
    color: var(--code-text);
    font-size: 14px;
    line-height: 1.75;
    overflow: auto;
    tab-size: 4;
}

.markdown-body pre code {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: inherit;
}

.code-copy {
    position: absolute;
    z-index: 2;
    top: 10px;
    right: 10px;
    display: inline-flex;
    min-height: 34px;
    padding: 0 10px;
    align-items: center;
    gap: 6px;
    border: 1px solid #334155;
    border-radius: 9px;
    background: #111c2f;
    color: #cbd5e1;
    font-family: var(--font-sans);
    font-size: 12px;
    cursor: pointer;
}

.code-copy:hover {
    border-color: #64748b;
    color: #fff;
}

.code-copy .icon {
    width: 15px;
    height: 15px;
}

/* Mermaid diagrams */

.mermaid-viewer {
    margin: 28px 0;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.mermaid-toolbar {
    display: flex;
    min-height: 50px;
    padding: 8px 10px 8px 16px;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-subtle);
}

.mermaid-title {
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 750;
}

.mermaid-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mermaid-action {
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--muted);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.mermaid-action:hover,
.mermaid-action.is-active {
    border-color: color-mix(in srgb, var(--accent) 44%, var(--border));
    background: var(--accent-soft);
    color: var(--accent);
}

.mermaid-fullscreen-button {
    margin-left: 4px;
}

.mermaid-stage {
    min-width: 0;
    background: var(--surface);
}

.mermaid-diagram {
    display: grid;
    min-height: 220px;
    padding: 28px;
    place-items: center;
    overflow: auto;
}

.mermaid-diagram[hidden],
.mermaid-source-panel[hidden] {
    display: none;
}

.mermaid-diagram svg {
    width: 100%;
    height: auto;
    max-height: 72vh;
}

.mermaid-source-panel {
    padding: 16px;
}

.markdown-body .mermaid-source-code {
    min-height: 220px;
    max-height: 68vh;
    margin: 0;
}

.mermaid-error {
    margin: 20px 0 8px;
    padding: 10px 13px;
    border: 1px solid #f59e0b;
    border-radius: 10px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 13px;
}

html[data-theme="dark"] .mermaid-error {
    background: #431407;
    color: #fed7aa;
}

body.mermaid-fullscreen-open {
    overflow: hidden;
}

.mermaid-viewer:fullscreen,
.mermaid-viewer.is-fullscreen,
.mermaid-viewer.is-fallback-fullscreen {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: var(--surface);
    flex-direction: column;
}

.mermaid-viewer.is-fallback-fullscreen {
    position: fixed;
    z-index: 1000;
    inset: 0;
}

.mermaid-viewer:fullscreen::backdrop {
    background: var(--surface);
}

.mermaid-viewer:fullscreen .mermaid-toolbar,
.mermaid-viewer.is-fullscreen .mermaid-toolbar,
.mermaid-viewer.is-fallback-fullscreen .mermaid-toolbar {
    flex: 0 0 auto;
    padding-right: max(16px, env(safe-area-inset-right));
    padding-left: max(16px, env(safe-area-inset-left));
}

.mermaid-viewer:fullscreen .mermaid-stage,
.mermaid-viewer.is-fullscreen .mermaid-stage,
.mermaid-viewer.is-fallback-fullscreen .mermaid-stage {
    display: grid;
    min-height: 0;
    flex: 1 1 auto;
}

.mermaid-viewer:fullscreen .mermaid-diagram,
.mermaid-viewer.is-fullscreen .mermaid-diagram,
.mermaid-viewer.is-fallback-fullscreen .mermaid-diagram,
.mermaid-viewer:fullscreen .mermaid-source-panel,
.mermaid-viewer.is-fullscreen .mermaid-source-panel,
.mermaid-viewer.is-fallback-fullscreen .mermaid-source-panel {
    min-height: 0;
    height: 100%;
    overflow: auto;
}

.mermaid-viewer:fullscreen .mermaid-diagram svg,
.mermaid-viewer.is-fullscreen .mermaid-diagram svg,
.mermaid-viewer.is-fallback-fullscreen .mermaid-diagram svg {
    width: min(100%, 2200px);
    max-width: min(100%, 2200px) !important;
    max-height: calc(100vh - 86px);
    max-height: calc(100dvh - 86px);
}

.mermaid-viewer:fullscreen .mermaid-source-code,
.mermaid-viewer.is-fullscreen .mermaid-source-code,
.mermaid-viewer.is-fallback-fullscreen .mermaid-source-code {
    min-height: 100%;
    max-height: none;
}

.markdown-body .table-scroll {
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow-x: auto;
}

.markdown-body table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: 14px;
    line-height: 1.6;
}

.markdown-body th,
.markdown-body td {
    min-width: 110px;
    padding: 12px 14px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.markdown-body th:last-child,
.markdown-body td:last-child {
    border-right: 0;
}

.markdown-body tr:last-child td {
    border-bottom: 0;
}

.markdown-body th {
    background: var(--surface-subtle);
    color: var(--text);
    font-weight: 720;
}

.markdown-body img {
    height: auto;
    margin: 1.6em auto;
    border-radius: 14px;
}

.markdown-body figure img {
    margin-bottom: 0.6em;
}

.markdown-body figcaption {
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.markdown-body hr {
    height: 1px;
    margin: 2.4em 0;
    border: 0;
    background: var(--border);
}

.markdown-body input[type="checkbox"] {
    width: 17px;
    height: 17px;
    margin: 0 8px 0 0;
    accent-color: var(--accent);
    vertical-align: -3px;
}

.markdown-body kbd {
    padding: 2px 7px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 3px;
    border-radius: 6px;
    background: var(--surface-subtle);
    color: var(--text);
    font-size: 0.82em;
}

.markdown-body mark {
    padding: 0.08em 0.18em;
    border-radius: 3px;
    background: #fef3c7;
    color: #713f12;
}

.markdown-body details {
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-subtle);
}

.markdown-body summary {
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}

.markdown-body .footnotes {
    margin-top: 3em;
    padding-top: 1em;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 14px;
}

.article-footer {
    margin-top: 42px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

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

.article-tags a {
    display: inline-flex;
    min-height: 34px;
    padding: 0 12px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-subtle);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.article-tags a::before {
    margin-right: 2px;
    content: "#";
    color: var(--accent);
}

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

/* Adjacent posts */

.post-near {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 16px;
    overflow: hidden;
}

.post-near-item {
    min-width: 0;
    padding: 20px 22px;
}

.post-near-item + .post-near-item {
    border-left: 1px solid var(--border);
}

.post-near-item > span {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 12px;
}

.post-near-item .icon {
    width: 16px;
    height: 16px;
}

.post-near-item > a {
    display: block;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.post-near-item > a:hover {
    color: var(--accent);
}

.post-near-next {
    text-align: right;
}

.post-near-next > span {
    justify-content: flex-end;
}

/* Comments */

.comments-card {
    margin-top: 16px;
    padding: 30px;
}

.comments-header h2,
.respond h2 {
    margin: 0 0 22px;
    color: var(--text);
    font-size: 22px;
}

.comment-list,
.comment-children {
    margin: 0;
    padding: 0;
    list-style: none;
}

.comment-list > .comment-body + .comment-body {
    margin-top: 14px;
}

.comment-list > .comment-body {
    position: relative;
    display: grid;
    padding: 18px;
    grid-template-columns: 44px minmax(0, 1fr);
    column-gap: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-subtle);
}

.comment-list > .comment-by-author {
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
    background: color-mix(in srgb, var(--accent) 4%, var(--surface));
}

.comment-body > .comment-author {
    display: grid;
    min-width: 0;
    grid-column: 1 / -1;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 14px;
}

.comment-author > span {
    grid-column: 1;
}

.comment-author .avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--border);
    object-fit: cover;
}

.comment-author .fn {
    min-width: 0;
    grid-column: 2;
    color: var(--text);
    font-size: 14px;
    font-style: normal;
    font-weight: 750;
    line-height: 1.35;
}

.comment-author .fn a {
    color: inherit;
}

.comment-body > .comment-meta,
.comment-body > .comment-content,
.comment-body > .comment-reply {
    min-width: 0;
    grid-column: 2;
}

.comment-body > .comment-meta {
    margin-top: -11px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
}

.comment-body > .comment-meta a,
.comment-body > .comment-meta time {
    color: inherit;
}

.comment-awaiting-moderation {
    display: block;
    margin-top: 5px;
    color: var(--signature);
    font-style: normal;
    font-weight: 650;
}

.comment-body > .comment-content {
    margin-top: 12px;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.75;
    overflow-wrap: anywhere;
}

.comment-content p {
    margin: 0 0 0.7em;
}

.comment-content p:last-child {
    margin-bottom: 0;
}

.comment-body > .comment-reply {
    margin-top: 9px;
}

.comment-reply a {
    display: inline-flex;
    min-height: 28px;
    padding: 0 9px;
    align-items: center;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
}

.comment-body > .comment-children {
    margin: 18px 0 0 30px;
    padding-left: 14px;
    grid-column: 1 / -1;
    border-left: 2px solid var(--accent-soft);
}

.comment-body > .respond {
    width: 100%;
    margin-top: 18px;
    padding-top: 18px;
    grid-column: 1 / -1;
}

.respond {
    margin-top: 30px;
    padding-top: 26px;
    border-top: 1px solid var(--border);
}

.comment-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.comment-form label > span,
.comment-textarea-label {
    display: block;
    margin-bottom: 7px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 700;
}

.comment-form input,
.comment-form textarea {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 11px;
    background: var(--surface-subtle);
    color: var(--text);
    outline: 0;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.comment-form input {
    height: 44px;
    padding: 0 12px;
}

.comment-form textarea {
    min-height: 150px;
    margin-top: 0;
    padding: 12px;
    resize: vertical;
}

.comment-textarea-label {
    margin-top: 16px;
}

.comment-form input:focus,
.comment-form textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.primary-button {
    display: inline-flex;
    min-height: 44px;
    margin-top: 14px;
    padding: 0 18px;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 11px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 750;
    cursor: pointer;
}

.primary-button:hover {
    background: var(--accent-strong);
}

.primary-button .icon {
    width: 17px;
    height: 17px;
}

.logged-in-note,
.comments-closed {
    color: var(--muted);
    font-size: 13px;
}

/* Pagination */

.page-navigator {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 26px 0 0;
    padding: 0;
    list-style: none;
}

.page-navigator a,
.page-navigator span {
    display: grid;
    min-width: 42px;
    min-height: 42px;
    padding: 0 12px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 700;
}

.page-navigator a:hover,
.page-navigator .current a,
.page-navigator .current span {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

/* Empty and error states */

.empty-state,
.error-card {
    padding: 54px 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.empty-state-mark {
    display: grid;
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
    place-items: center;
    border-radius: 18px;
    background: var(--accent-soft);
    color: var(--accent);
}

.empty-state-mark .icon {
    width: 28px;
    height: 28px;
}

.empty-state h2,
.error-card h1 {
    margin: 0;
    color: var(--text);
}

.empty-state p,
.error-card p {
    margin: 8px 0 0;
    color: var(--muted);
}

.error-layout {
    display: grid;
    min-height: calc(100vh - var(--header-height) - 130px);
    padding: 60px 20px;
    place-items: center;
}

.error-card {
    width: min(100%, 680px);
}

.error-code {
    display: block;
    color: var(--accent);
    font-size: clamp(64px, 12vw, 112px);
    font-weight: 850;
    line-height: 1;
    letter-spacing: -0.06em;
}

.error-search {
    margin-top: 24px;
}

.text-link {
    display: inline-flex;
    margin-top: 22px;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    font-weight: 700;
}

.text-link .icon {
    width: 17px;
    height: 17px;
}

/* Footer */

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.footer-inner {
    display: flex;
    width: min(calc(100% - var(--page-gutter) - var(--page-gutter)), var(--container));
    min-height: 92px;
    margin: 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    color: var(--muted);
    font-size: 12px;
}

.footer-inner p {
    margin: 0;
}

.footer-copy {
    display: grid;
    gap: 6px;
}

.footer-record {
    white-space: nowrap;
}

.footer-inner a {
    color: var(--text-soft);
    font-weight: 700;
}

.back-to-top {
    position: fixed;
    z-index: 80;
    right: 22px;
    bottom: 22px;
    display: grid;
    width: 44px;
    height: 44px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    color: var(--text);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 160ms ease, transform 160ms ease, color 160ms ease;
}

.back-to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.back-to-top:hover {
    color: var(--accent);
}

/* Dark-specific corrections */

html[data-theme="dark"] .post-card:hover {
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .markdown-body mark {
    background: #713f12;
    color: #fef3c7;
}

/* Responsive */

@media (min-width: 1440px) {
    :root {
        --container: 1320px;
        --sidebar-width: 310px;
        --layout-gap: 30px;
    }
}

@media (min-width: 1680px) {
    :root {
        --container: 1520px;
        --sidebar-width: 320px;
        --layout-gap: 32px;
    }
}

@media (min-width: 1920px) {
    :root {
        --container: 1720px;
        --sidebar-width: 330px;
        --layout-gap: 34px;
    }
}

@media (min-width: 2560px) {
    :root {
        --container: 2200px;
        --sidebar-width: 360px;
        --layout-gap: 40px;
        --page-gutter: 28px;
    }
}

@media (min-width: 3200px) {
    :root {
        --container: 2600px;
        --sidebar-width: 380px;
        --layout-gap: 44px;
        --page-gutter: 36px;
    }
}

@media (max-width: 1080px) {
    .header-inner,
    .page-shell,
    .footer-inner {
        width: min(calc(100% - 32px), var(--container));
    }

    .header-inner {
        grid-template-columns: minmax(170px, 1fr) auto minmax(120px, 1fr);
    }

    .site-nav {
        gap: 24px;
    }

    .page-shell {
        grid-template-columns: minmax(0, 1fr) 280px;
        gap: 20px;
    }

    .post-card-content {
        padding: 22px;
    }

    .article-card {
        padding: 36px;
    }
}

@media (max-width: 960px) {
    .page-shell {
        grid-template-columns: minmax(0, 1fr);
        max-width: 820px;
    }

    .sidebar-sticky {
        position: static;
        min-height: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sidebar-persistent {
        display: contents;
    }

    .sidebar-persistent > .sidebar-scroll-body {
        display: contents;
    }

    .sidebar-toc-shell {
        display: none !important;
    }

    .is-post .sidebar,
    .is-page .sidebar {
        align-self: start;
    }

    :is(.is-post, .is-page) .sidebar[data-sidebar-mode="toc"] .sidebar-toc-shell,
    :is(.is-post, .is-page) .sidebar[data-sidebar-mode="content"] .sidebar-persistent {
        position: static;
        width: auto;
        margin-right: 0;
        background: transparent;
    }

    :is(.is-post, .is-page) .sidebar[data-sidebar-mode="toc"] .sidebar-toc-shell::before,
    :is(.is-post, .is-page) .sidebar[data-sidebar-mode="content"] .sidebar-persistent::before {
        content: none;
    }

    :is(.is-post, .is-page) .sidebar[data-sidebar-mode="toc"] .sidebar-toc-shell > .sidebar-scroll-body,
    :is(.is-post, .is-page) .sidebar[data-sidebar-mode="content"] .sidebar-persistent > .sidebar-scroll-body {
        max-height: none;
        padding-right: 0;
        overflow: visible;
        overscroll-behavior: auto;
        scrollbar-gutter: auto;
        scrollbar-width: auto;
    }

    .profile-card {
        grid-row: span 2;
    }

    .toc-widget {
        display: none !important;
    }

    .mobile-toc-toggle {
        display: inline-flex;
        min-height: 44px;
        margin-top: 18px;
        padding: 0 14px;
        align-items: center;
        gap: 8px;
        border: 1px solid var(--border);
        border-radius: 11px;
        background: var(--surface-subtle);
        color: var(--text-soft);
        font-size: 13px;
        font-weight: 750;
        cursor: pointer;
    }

    .mobile-toc-toggle .icon {
        width: 17px;
        height: 17px;
        transition: transform 160ms ease;
    }

    .mobile-toc-toggle[aria-expanded="true"] .icon {
        transform: rotate(180deg);
    }

    .mobile-toc-panel {
        display: block;
        margin-top: 12px;
        padding: 12px 14px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--surface-subtle);
    }
}

@media (max-width: 760px) {
    :root {
        --header-height: 62px;
    }

    .header-inner {
        display: flex;
        width: calc(100% - 28px);
        justify-content: space-between;
    }

    .brand {
        min-width: 0;
        font-size: 16px;
    }

    .brand-mark {
        width: 32px;
        height: 32px;
    }

    .site-nav {
        position: absolute;
        z-index: 99;
        top: 100%;
        right: 0;
        bottom: auto;
        left: 0;
        display: flex;
        height: calc(100vh - var(--header-height));
        height: calc(100dvh - var(--header-height));
        padding: 24px 20px 40px;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        background: var(--surface);
        opacity: 0;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        pointer-events: none;
        transform: translateY(-10px);
        visibility: hidden;
        transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 160ms;
        -webkit-overflow-scrolling: touch;
    }

    .nav-open .site-nav {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
        visibility: visible;
        transition-delay: 0s;
    }

    .site-nav a {
        min-height: 52px;
        padding: 0 14px;
        border-radius: 12px;
        font-size: 17px;
    }

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

    .site-nav a:hover,
    .site-nav a.is-current {
        background: var(--accent-soft);
    }

    .menu-toggle {
        display: inline-grid;
    }

    .nav-open .menu-toggle .icon-menu {
        display: none;
    }

    .nav-open .menu-toggle .icon-close {
        display: block;
    }

    .page-shell {
        width: calc(100% - 28px);
        padding: 30px 0 52px;
    }

    .page-intro {
        margin-bottom: 20px;
    }

    .page-intro h1 {
        font-size: 31px;
    }

    .post-card-content {
        padding: 21px 20px;
        border-left: 0;
        border-top: 4px solid var(--accent);
    }

    .post-card-title {
        font-size: 21px;
    }

    .post-card-meta {
        gap: 12px;
        flex-wrap: wrap;
    }

    .post-card-read {
        margin-left: 0;
    }

    .sidebar-sticky {
        grid-template-columns: minmax(0, 1fr);
    }

    .profile-card {
        grid-row: auto;
    }

    .article-card {
        padding: 26px 22px 32px;
    }

    .article-header {
        margin-bottom: 26px;
        padding-bottom: 20px;
    }

    .article-header h1 {
        font-size: 30px;
    }

    .markdown-body {
        font-size: 16px;
        line-height: 1.86;
    }

    .heading-anchor {
        display: none;
    }

    .markdown-body h2 {
        font-size: 1.42em;
    }

    .markdown-body pre {
        margin-right: -6px;
        margin-left: -6px;
        padding: 20px 18px;
        font-size: 13px;
    }

    .mermaid-viewer {
        margin-right: -6px;
        margin-left: -6px;
    }

    .mermaid-toolbar {
        padding: 9px 10px;
        align-items: flex-start;
        flex-direction: column;
    }

    .mermaid-actions {
        width: 100%;
    }

    .mermaid-action {
        flex: 1 1 auto;
    }

    .mermaid-diagram {
        min-height: 180px;
        padding: 18px 12px;
    }

    .mermaid-source-panel {
        padding: 10px;
    }

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

    .post-near-item + .post-near-item {
        border-top: 1px solid var(--border);
        border-left: 0;
    }

    .post-near-next {
        text-align: left;
    }

    .post-near-next > span {
        justify-content: flex-start;
    }

    .comments-card {
        padding: 24px 20px;
    }

    .comment-fields {
        grid-template-columns: 1fr;
    }

    .comment-body > .comment-children {
        margin-left: 18px;
    }

    .footer-inner {
        width: calc(100% - 28px);
        min-height: 120px;
        padding: 24px 0;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        gap: 5px;
    }

    .back-to-top {
        right: 14px;
        bottom: 14px;
    }
}

@media (max-width: 480px) {
    .brand-text {
        max-width: 145px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-actions {
        gap: 0;
    }

    .icon-button {
        width: 42px;
        height: 42px;
    }

    .page-shell {
        width: calc(100% - 22px);
    }

    .page-intro h1 {
        font-size: 28px;
    }

    .post-card-content {
        padding: 19px 17px;
    }

    .post-card-title {
        font-size: 20px;
    }

    .post-card-meta > span:nth-child(2) {
        display: none;
    }

    .article-card {
        padding: 23px 17px 28px;
    }

    .article-header h1 {
        font-size: 27px;
    }

    .article-meta {
        gap: 8px 14px;
    }

    .markdown-body h2::before {
        width: 3px;
        margin-right: 7px;
    }

    .comment-list > .comment-body {
        padding: 14px;
        grid-template-columns: 36px minmax(0, 1fr);
        column-gap: 10px;
    }

    .comment-body > .comment-author {
        grid-template-columns: 36px minmax(0, 1fr);
        gap: 10px;
    }

    .comment-author .avatar {
        width: 36px;
        height: 36px;
    }

    .comment-body > .comment-meta {
        margin-top: -8px;
    }

    .comment-body > .comment-content,
    .comment-body > .comment-reply {
        grid-column: 1 / -1;
    }

    .comment-body > .comment-children {
        margin-left: 8px;
        padding-left: 9px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media print {
    .site-header,
    .sidebar,
    .site-footer,
    .back-to-top,
    .comments-card,
    .post-near,
    .mobile-toc-toggle,
    .mobile-toc-panel,
    .code-copy,
    .mermaid-toolbar,
    .mermaid-source-panel {
        display: none !important;
    }

    .mermaid-diagram {
        display: grid !important;
    }

    body,
    .article-card {
        background: #fff;
        color: #000;
    }

    .page-shell {
        display: block;
        width: 100%;
        padding: 0;
    }

    .article-card {
        padding: 0;
        border: 0;
        box-shadow: none;
    }
}
