/* ============================================================
   个人主页样式 — 简约 / 留白 / 浅色优先
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --surface: #ffffff;
  --surface-hover: #fbfbfd;
  --border: #e7e9ee;
  --border-strong: #d8dbe2;
  --text: #1b1f24;
  --text-2: #4b5563;
  --muted: #8a909a;
  --accent: #4f46e5;
  --accent-2: #6d5ef0;
  --accent-soft: #eef0ff;
  --accent-text: #4338ca;
  --code-bg: #f6f8fa;
  --code-border: #e6e8ec;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lg: 0 18px 40px rgba(16, 24, 40, .10), 0 2px 8px rgba(16, 24, 40, .04);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 300px;
  --wrap: 900px;
  --header-h: 68px;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --bg-soft: #151820;
  --surface: #171a21;
  --surface-hover: #1d212a;
  --border: #282d37;
  --border-strong: #353b47;
  --text: #eef0f4;
  --text-2: #c0c6d0;
  --muted: #8b93a1;
  --accent: #8b83ff;
  --accent-2: #a29bff;
  --accent-soft: #232340;
  --accent-text: #b9b3ff;
  --code-bg: #0d1117;
  --code-border: #262b35;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .34), 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .4);
}

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

[hidden] { display: none !important; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 20px); overflow-x: hidden; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }
img { max-width: 100%; }

.icon { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon svg { width: 1em; height: 1em; display: block; }

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

.skip-link {
  position: fixed; top: -60px; left: 16px; z-index: 100;
  padding: 8px 14px; border-radius: 8px;
  background: var(--accent); color: #fff;
  transition: top .2s;
}
.skip-link:focus { top: 12px; }

/* ---------------- 顶部导航 ---------------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner { height: 100%; display: flex; align-items: center; gap: 28px; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 15px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .25);
}
.brand-name { font-size: 16px; }

.site-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-link {
  padding: 7px 13px; border-radius: 8px;
  font-size: 14px; color: var(--text-2);
  transition: color .18s, background-color .18s;
}
.nav-link:hover { color: var(--accent); background: var(--accent-soft); }
.nav-link.active { color: var(--accent); font-weight: 600; }

.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-2);
  display: grid; place-items: center; cursor: pointer;
  font-size: 18px; transition: background-color .18s, color .18s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--accent); }
.menu-btn { display: none; }
.theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-sun { display: inline-flex; }
[data-theme="dark"] .theme-icon-moon { display: none; }

/* ---------------- 左侧固定个人简介侧栏 ---------------- */

.page-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
}

.sidebar {
  align-self: stretch;
  min-height: 100vh;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 44px 28px 30px;
}
.sidebar-inner { display: flex; flex-direction: column; min-height: calc(100vh - 74px); }
.sidebar-head { text-align: center; }

.avatar-frame {
  width: 132px; height: 132px; border-radius: 50%; overflow: hidden;
  margin: 0 auto; border: 4px solid var(--surface);
  box-shadow: var(--shadow-lg); background: var(--surface);
}
.avatar-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }

.sidebar-name {
  margin: 20px 0 5px; font-size: 24px; line-height: 1.3;
  letter-spacing: -.035em; font-weight: 720;
}
.sidebar-en { display: block; margin-top: 3px; color: var(--muted); font-size: 12.5px; font-weight: 500; letter-spacing: 0; }
.sidebar-role { margin: 0; color: var(--accent); font-size: 13.5px; font-weight: 600; }

.sidebar-callsign {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 12px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--accent-text);
  font-size: 12.5px;
}
.sidebar-callsign .icon { color: var(--accent); font-size: 15px; }
.sidebar-callsign strong { font-weight: 700; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.sidebar-callsign span { color: var(--muted); font-size: 11px; }

.sidebar-bio {
  margin: 24px 0 0; color: var(--text-2); font-size: 13px;
  line-height: 1.8; overflow-wrap: anywhere;
}

.sidebar-skills {
  margin-top: 22px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
.sidebar-subtitle {
  margin: 0 0 14px; color: var(--muted);
  font-size: 11.5px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
}
.sidebar-skills .skills-grid { grid-template-columns: 1fr; gap: 12px; }
.sidebar-skills .skill-top { font-size: 12.5px; margin-bottom: 6px; }
.sidebar-skills .skill-level { font-size: 11.5px; }
.sidebar-skills .skill-track { height: 5px; }

.sidebar-facts {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 20px; padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12.5px;
}
.sidebar-facts span { display: flex; align-items: center; gap: 8px; }
.sidebar-facts .icon { color: var(--accent); font-size: 14px; }

.sidebar-socials { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.social-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 11px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  font-size: 12px; font-weight: 500;
  transition: transform .18s, border-color .18s, color .18s, box-shadow .18s;
}
.social-link .icon { font-size: 14px; }
.social-link:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); box-shadow: var(--shadow-sm); }

.sidebar-stats { display: flex; margin-top: auto; padding-top: 28px; }
.sidebar-stats div {
  flex: 1; text-align: center;
  display: flex; flex-direction: column; gap: 1px;
}
.sidebar-stats div + div { border-left: 1px solid var(--border); }
.sidebar-stats strong { font-size: 19px; line-height: 1.2; letter-spacing: -.02em; }
.sidebar-stats span { font-size: 11px; color: var(--muted); }

.main-column { min-width: 0; display: flex; flex-direction: column; }
.main-column .site-footer { margin-top: auto; }
.section-first { padding-top: 56px; }

/* ---------------- 通用区块 ---------------- */

.section { padding: 78px 0; }
.section-soft { background: var(--bg-soft); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.section-head { margin-bottom: 36px; }
.section-kicker {
  display: inline-block; font-size: 11.5px; font-weight: 700;
  letter-spacing: .16em; color: var(--accent); text-transform: uppercase;
  margin-bottom: 10px;
}
.section-title { margin: 0; font-size: clamp(26px, 3.4vw, 32px); letter-spacing: -.035em; font-weight: 720; line-height: 1.25; }
.section-desc { margin: 10px 0 0; color: var(--muted); font-size: 14.5px; }

.block-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 18px; font-size: 17px; font-weight: 650; letter-spacing: -.01em;
}
.block-title .icon { color: var(--accent); font-size: 16px; }
.block-divider { height: 1px; background: var(--border); margin: 46px 0 32px; }
.empty-hint { color: var(--muted); font-size: 14px; padding: 18px 0; }
.empty-hint code { background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 5px; padding: 1px 5px; font-size: .9em; }

/* ---------------- 技能 ---------------- */

.skills-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 44px; }
.skill-item { min-width: 0; }
.skill-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; font-size: 14px; }
.skill-name { display: inline-flex; align-items: center; gap: 9px; font-weight: 550; }
.skill-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.skill-level { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.skill-track { height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.skill-fill { height: 100%; border-radius: 99px; transition: width 1s cubic-bezier(.2, .8, .2, 1); }

/* ---------------- 开源项目 ---------------- */

.projects-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.project-card {
  display: flex; flex-direction: column;
  padding: 24px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.project-card:hover { transform: translateY(-4px); border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.project-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.project-icon {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 19px;
}
.project-arrow { color: var(--muted); font-size: 18px; transition: transform .2s, color .2s; }
.project-card:hover .project-arrow { transform: translate(3px, -3px); color: var(--accent); }
.project-name { margin: 0 0 8px; font-size: 17px; letter-spacing: -.02em; }
.project-desc { margin: 0; flex: 1; color: var(--text-2); font-size: 13.5px; line-height: 1.7; }
.project-meta { display: flex; align-items: center; gap: 18px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.project-lang, .project-stars { display: inline-flex; align-items: center; gap: 6px; }
.project-stars .icon { color: #e0a428; font-size: 13px; }

/* ---------------- 文章卡片 / 列表 ---------------- */

.post-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.post-card {
  display: flex; flex-direction: column; min-height: 210px;
  padding: 22px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.post-card:hover { transform: translateY(-4px); border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.post-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.cat-badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text);
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.pin-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 999px;
  background: #fff4e5; color: #b45309; font-size: 11px; font-weight: 600; white-space: nowrap;
}
[data-theme="dark"] .pin-badge { background: #3a2b16; color: #f0b866; }
.pin-badge .icon { font-size: 11px; }
.post-card-title { margin: 0 0 8px; font-size: 17px; line-height: 1.45; letter-spacing: -.02em; transition: color .18s; }
.post-card:hover .post-card-title { color: var(--accent); }
.post-card-desc { margin: 0; flex: 1; color: var(--text-2); font-size: 13.5px; line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.card-arrow { color: var(--muted); font-size: 16px; transition: transform .2s, color .2s; }
.post-card:hover .card-arrow { transform: translateX(4px); color: var(--accent); }

.post-list { display: flex; flex-direction: column; }
.post-row {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 18px; margin: 0 -18px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--border);
  transition: background-color .18s, transform .18s;
}
.post-row:last-child { border-bottom: 0; }
.post-row:hover { background: var(--surface-hover); transform: translateX(3px); }
.post-row-icon {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 17px;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--muted);
}
.post-row:hover .post-row-icon { color: var(--accent); border-color: var(--accent); }
.post-row-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.post-row-title { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; transition: color .18s; }
.post-row:hover .post-row-title { color: var(--accent); }
.inline-pin { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: #b45309; background: #fff4e5; padding: 2px 7px; border-radius: 999px; }
[data-theme="dark"] .inline-pin { background: #3a2b16; color: #f0b866; }
.inline-pin .icon { font-size: 10px; }
.post-row-desc { color: var(--text-2); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-row-meta { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.post-row-meta i { width: 3px; height: 3px; border-radius: 50%; background: var(--border-strong); }
.post-row-arrow { color: var(--muted); font-size: 18px; opacity: 0; transform: translateX(-6px); transition: opacity .18s, transform .18s, color .18s; }
.post-row:hover .post-row-arrow { opacity: 1; transform: translateX(0); color: var(--accent); }

.section-more { margin-top: 36px; text-align: center; }
.more-link {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 11px 22px; border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: 14px; font-weight: 550; color: var(--text-2);
  transition: border-color .18s, color .18s, background-color .18s;
}
.more-link:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.more-link .icon { font-size: 16px; }

/* ---------------- 列表页 ---------------- */

.page-head { padding-top: 64px; padding-bottom: 38px; border-bottom: 1px solid var(--border); }
.page-head h1 { margin: 0; font-size: clamp(32px, 4.5vw, 44px); letter-spacing: -.045em; line-height: 1.2; }
.page-head p { margin: 10px 0 0; color: var(--muted); font-size: 14.5px; }
.page-head .page-count { margin-top: 4px; font-size: 13px; }
.page-body { padding-top: 44px; padding-bottom: 88px; }
.pinned-section { margin-bottom: 48px; }
.list-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 12px; }
.list-head .block-title { margin: 0; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-pill {
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-2); font-size: 13px; cursor: pointer;
  transition: all .18s;
}
.filter-pill span { color: var(--muted); font-size: 11px; margin-left: 3px; }
.filter-pill:hover { border-color: var(--accent); color: var(--accent); }
.filter-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-pill.active span { color: rgba(255, 255, 255, .75); }

/* ---------------- 文章页 ---------------- */

.article-wrap { max-width: 820px; padding-top: 42px; padding-bottom: 90px; }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; color: var(--muted); font-size: 13px; margin-bottom: 36px; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { opacity: .5; }

.article-head { margin-bottom: 40px; padding-bottom: 34px; border-bottom: 1px solid var(--border); }
.article-badges { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.article-head h1 { margin: 0; font-size: clamp(30px, 4.5vw, 42px); line-height: 1.3; letter-spacing: -.04em; font-weight: 720; }
.article-lead { margin: 16px 0 0; color: var(--text-2); font-size: 16px; line-height: 1.8; }
.article-meta { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 20px; color: var(--muted); font-size: 13px; }
.article-meta span { display: inline-flex; align-items: center; gap: 6px; }
.article-meta .icon { color: var(--accent); font-size: 15px; }
.article-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tag { padding: 4px 10px; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-2); font-size: 12px; }

.article-body { color: var(--text); font-size: 16px; line-height: 1.9; }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  margin: 1.9em 0 .7em; line-height: 1.35; letter-spacing: -.025em; scroll-margin-top: calc(var(--header-h) + 24px);
}
.markdown-body h1 { font-size: 1.7em; }
.markdown-body h2 { font-size: 1.42em; padding-bottom: .35em; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body h4 { font-size: 1.06em; }
.markdown-body p { margin: 1em 0; }
.markdown-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.markdown-body a:hover { text-decoration-thickness: 2px; }
.markdown-body strong { font-weight: 700; }
.markdown-body ul, .markdown-body ol { padding-left: 1.6em; margin: 1em 0; }
.markdown-body li { margin: .35em 0; }
.markdown-body li::marker { color: var(--accent); }
.markdown-body blockquote {
  margin: 1.5em 0; padding: 2px 18px;
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 0 8px 8px 0; color: var(--text-2);
}
.markdown-body blockquote p { margin: .6em 0; }
.markdown-body code {
  padding: .15em .4em; border-radius: 5px;
  background: var(--code-bg); border: 1px solid var(--code-border);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: .875em; color: var(--accent-text);
}
.markdown-body pre {
  margin: 1.5em 0; padding: 18px 20px;
  background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 12px;
  overflow-x: auto; line-height: 1.65; font-size: 13.5px;
}
.markdown-body pre code { padding: 0; border: 0; background: none; color: inherit; font-size: inherit; }
.markdown-body img { display: block; max-width: 100%; margin: 1.6em auto; border-radius: 10px; }
.markdown-body hr { margin: 2.4em 0; border: 0; border-top: 1px solid var(--border); }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: 14px; display: block; overflow-x: auto; }
.markdown-body th, .markdown-body td { padding: 9px 14px; border: 1px solid var(--border); text-align: left; }
.markdown-body th { background: var(--bg-soft); font-weight: 600; }
.markdown-body tr:nth-child(even) { background: var(--bg-soft); }

.article-end { display: flex; align-items: center; gap: 18px; margin: 52px 0 32px; color: var(--muted); font-size: 12px; letter-spacing: .2em; }
.article-end::before, .article-end::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.article-bottom { margin-bottom: 34px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 14px; }
.back-link:hover { color: var(--accent); }
.back-link .icon { font-size: 16px; }

.article-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.article-nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); transition: border-color .18s, box-shadow .18s;
}
.article-nav-item:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.article-nav-item > .icon { color: var(--accent); font-size: 18px; }
.article-nav-item span { display: flex; flex-direction: column; min-width: 0; font-size: 14px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.article-nav-item small { color: var(--muted); font-size: 11.5px; font-weight: 400; margin-bottom: 2px; }
.article-nav-item.next { justify-content: flex-end; text-align: right; }

/* ---------------- 页脚 ---------------- */

.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-top: 26px; padding-bottom: 26px; }
.footer-inner p { margin: 0; color: var(--muted); font-size: 12.5px; }
.footer-inner a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }
.footer-inner a:hover { color: var(--accent); }
.footer-inner .icon { font-size: 14px; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 980px) {
  .page-shell { display: flex; flex-direction: column; }
  .main-column { display: contents; }
  .site-header { order: 1; }
  .sidebar {
    order: 2; position: static; align-self: stretch; width: 100%;
    height: auto; min-height: 0; overflow: visible;
    border-right: 0; border-bottom: 1px solid var(--border);
    padding: 36px 24px 28px;
  }
  #main { order: 3; width: 100%; }
  .site-header { width: 100%; }
  .site-footer { order: 4; width: 100%; }
  .sidebar-inner { min-height: 0; }
  .sidebar-bio, .sidebar-facts, .sidebar-socials, .sidebar-stats {
    width: 100%; max-width: 640px; margin-left: auto; margin-right: auto;
  }
  .sidebar-facts { flex-direction: row; flex-wrap: wrap; gap: 8px 24px; }
  .sidebar-stats { margin-top: 24px; padding-top: 0; }
  .projects-grid, .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-link { padding: 7px 9px; }
}

@media (max-width: 640px) {
  :root { --header-h: 60px; }
  .wrap { padding: 0 20px; }
  .brand-name { display: inline; font-size: 15px; }
  .site-nav {
    position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    padding: 10px 20px 16px;
    background: var(--bg); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transform-origin: top; transform: scaleY(0); opacity: 0;
    transition: transform .18s, opacity .18s;
    pointer-events: none;
  }
  .site-nav.open { transform: scaleY(1); opacity: 1; pointer-events: auto; }
  .nav-link { padding: 10px 12px; }
  .menu-btn { display: grid; }
  .sidebar { padding: 28px 20px 24px; }
  .avatar-frame { width: 104px; height: 104px; border-width: 3px; }
  .sidebar-name { margin-top: 12px; font-size: 21px; }
  .sidebar-bio { margin-top: 16px; }
  .sidebar-skills { margin-top: 18px; padding-top: 16px; }
  .sidebar-skills .skills-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
  .sidebar-socials { margin-top: 18px; }
  .sidebar-stats { margin-top: 20px; }
  .section { padding: 58px 0; }
  .section-first { padding-top: 44px; }
  .projects-grid, .post-grid { grid-template-columns: 1fr; }
  .skills-grid { gap: 18px; }
  .page-head { padding-top: 46px; }
  .list-head { align-items: flex-start; flex-direction: column; }
  .article-wrap { padding-top: 30px; }
  .article-nav { grid-template-columns: 1fr; }
  .post-row { padding: 16px 10px; margin: 0 -10px; gap: 12px; }
  .post-row-desc { white-space: normal; }
  .footer-inner { flex-direction: column; align-items: flex-start; }

  .compact-sidebar .sidebar { padding: 16px 20px 14px; }
  .compact-sidebar .sidebar-inner { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
  .compact-sidebar .sidebar-head { display: flex; align-items: center; gap: 12px; text-align: left; margin: 0; }
  .compact-sidebar .avatar-frame { width: 48px; height: 48px; border-width: 2px; margin: 0; }
  .compact-sidebar .sidebar-name { margin: 0; font-size: 16px; }
  .compact-sidebar .sidebar-en { display: inline; margin: 0 0 0 4px; font-size: 11px; }
  .compact-sidebar .sidebar-role { display: none; }
  .compact-sidebar .sidebar-callsign { margin: 0; padding: 4px 9px; }
  .compact-sidebar .sidebar-callsign span { display: none; }
  .compact-sidebar .sidebar-bio,
  .compact-sidebar .sidebar-skills,
  .compact-sidebar .sidebar-facts,
  .compact-sidebar .sidebar-socials,
  .compact-sidebar .sidebar-stats { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
