:root {
  color-scheme: light dark;

  --bg: #f7f8f5;
  --surface: #fcfdfb;
  --text: #1d231f;
  --muted: #636b65;
  --faint: #6b746d;
  --border: #dbe0da;
  --border-soft: #e8ece7;
  --accent: #166a52;
  --accent-strong: #0d503d;
  --accent-soft: rgba(22, 106, 82, 0.09);
  --code-bg: #eef1ed;
  --code-border: #dbe0da;

  --mono: "JetBrainsMono Nerd Font Mono", "JetBrainsMono Nerd Font",
    "JetBrains Mono", "Fira Code", "Noto Sans Mono CJK SC",
    "Sarasa Mono SC", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --width: 84ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1210;
    --surface: #131815;
    --text: #e4e9e5;
    --muted: #9ba59e;
    --faint: #7b857e;
    --border: #273029;
    --border-soft: #1c231e;
    --accent: #79c7a9;
    --accent-strong: #a2ddc5;
    --accent-soft: rgba(121, 199, 169, 0.11);
    --code-bg: #171d19;
    --code-border: #273029;
  }
}

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

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 14.5px;
  line-height: 1.9;
  font-variant-ligatures: none;
  font-feature-settings: "tnum" 1, "zero" 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent-soft);
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover,
a:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.skip-link:focus {
  top: 12px;
}

#main:focus {
  outline: none;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px 28px;
  width: min(var(--width), calc(100% - 32px));
  margin: 0 auto;
  padding: 13px 0 11px;
}

.brand {
  flex: none;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.brand span {
  color: var(--faint);
  font-weight: 400;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.1em;
  color: var(--muted);
  font-size: 13px;
}

.nav a {
  padding: 0 0.55em;
  border-left: 1px solid var(--border);
}

.nav a:first-child {
  border-left: 0;
  padding-left: 0;
}

.nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 700;
}

/* Home layout */
.container {
  width: min(var(--width), calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 60px;
}

.hero {
  padding-bottom: 38px;
  border-bottom: 1px solid var(--border);
}

.kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.045em;
}

.tagline {
  margin: 10px 0 0;
  color: var(--accent);
  font-size: 14px;
}

.bio {
  max-width: 64ch;
  margin: 18px 0 0;
  color: var(--muted);
}

.links {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.links a {
  color: var(--accent);
}

.links .sep {
  color: var(--faint);
}

/* Sections */
.section {
  margin-top: 44px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.section-head h1,
.section-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.section-head .more {
  color: var(--muted);
  font-size: 12px;
}

/* Project table */
.projects {
  width: 100%;
  margin-top: 5px;
  border-collapse: collapse;
  font-size: 13px;
}

.projects th {
  padding: 10px 12px 8px 0;
  color: var(--faint);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

.projects td {
  padding: 10px 12px 10px 0;
  color: var(--muted);
  vertical-align: top;
  border-bottom: 1px solid var(--border-soft);
}

.projects .name {
  color: var(--text);
  font-weight: 700;
}

.projects .name a:hover {
  color: var(--accent);
}

.projects .state {
  white-space: nowrap;
}

.projects .state.active {
  color: var(--accent);
}

.projects .links {
  white-space: nowrap;
}

.projects .links a {
  color: var(--accent);
}

/* Writing list */
.writing {
  margin: 5px 0 0;
  padding: 0;
  list-style: none;
}

.writing li {
  display: grid;
  grid-template-columns: 10ch minmax(0, 1fr);
  align-items: baseline;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}

.writing time {
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.writing .title {
  color: var(--text);
}

.writing .title:hover {
  color: var(--accent);
}

.writing .desc {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* Machine-readable */
.machine {
  margin-top: 44px;
  padding: 18px 20px 20px;
  border: 1px solid var(--border);
  background: var(--code-bg);
}

.machine h2 {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.machine p {
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 12px;
}

.machine pre {
  margin: 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.8;
}

.machine code {
  white-space: pre;
}

/* Article */
.article-container {
  width: min(72ch, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 72px;
}

.back {
  display: inline-block;
  margin-bottom: 34px;
  color: var(--muted);
  font-size: 13px;
}

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

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

.article-meta {
  margin: 0 0 13px;
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

.article-header h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.035em;
}

.article-header .lead {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.9;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 18px;
}

.tag {
  display: inline-block;
  padding: 0 7px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.prose {
  max-width: 68ch;
  padding-top: 34px;
  font-size: 14.5px;
  line-height: 1.95;
}

.prose > :first-child {
  margin-top: 0;
}

.prose h2 {
  margin: 2.3em 0 0.7em;
  font-size: 18px;
  line-height: 1.5;
  letter-spacing: -0.015em;
}

.prose h3 {
  margin: 1.8em 0 0.6em;
  font-size: 15.5px;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose pre,
.prose table {
  margin: 0 0 1.35em;
}

.prose ul,
.prose ol {
  padding-left: 1.5em;
}

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

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.prose code {
  padding: 0.08em 0.35em;
  border: 1px solid var(--code-border);
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 0.92em;
}

.prose pre {
  overflow-x: auto;
  padding: 16px 18px;
  border: 1px solid var(--code-border);
  background: var(--code-bg);
  line-height: 1.7;
}

.prose pre code {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 12.5px;
}

.prose blockquote {
  margin-left: 0;
  padding: 2px 0 2px 16px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}

.prose hr {
  height: 1px;
  margin: 2.5em 0;
  border: 0;
  background: var(--border);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.prose th,
.prose td {
  padding: 7px 10px 7px 0;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}

.prose th {
  color: var(--faint);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 50px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.post-nav a {
  display: block;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
}

.post-nav a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.post-nav .label {
  display: block;
  margin-bottom: 4px;
  color: var(--faint);
  font-size: 11px;
}

.post-nav strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* Footer */
.footer {
  width: min(var(--width), calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 42px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 12px;
  line-height: 2;
}

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

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

/* Responsive */
@media (max-width: 680px) {
  .site-header-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .nav a {
    padding: 0 0.45em;
  }

  .container {
    padding-top: 36px;
  }

  .projects {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .writing li {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .article-container {
    padding-top: 30px;
  }

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

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


/* home-v5: single column, wide table, terminal typography.
   Loaded after terminal-v2.css. */

:root {
  --width: min(1024px, calc(100% - 48px));
}

.nav {
  gap: 0 14px;
}

.nav a {
  padding: 0;
  border-left: 0;
}

.hero {
  padding-bottom: 30px;
}

.hero h1 {
  font-size: clamp(34px, 5vw, 54px);
  letter-spacing: -0.055em;
}

.tagline {
  margin-top: 9px;
  letter-spacing: 0.02em;
  text-transform: none;
}

.bio {
  max-width: 82ch;
  margin-top: 16px;
}

/* NOW: kept useful, but inline rather than a sidebar card */
.now {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px 22px;
  margin-top: 22px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.8;
}

.now .label {
  color: var(--accent);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.section {
  margin-top: 42px;
}

.section-head {
  padding-bottom: 7px;
}

/* Wide project table */
.projects {
  width: 100%;
}

.projects th,
.projects td {
  padding-top: 9px;
  padding-bottom: 9px;
}

.projects th:nth-child(4),
.projects td:nth-child(4) {
  width: 36%;
}

.projects th:nth-child(5),
.projects td:nth-child(5) {
  width: 10%;
  white-space: nowrap;
}

.projects .links a {
  color: var(--accent);
}

/* Writing list */
.writing {
  max-width: 100%;
}

.writing li {
  padding: 9px 0;
}

.writing .desc {
  max-width: 96ch;
  margin-top: 1px;
}

/* Footer */
.footer {
  line-height: 1.9;
}

.footer .meta-links {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin-top: 6px;
}

.footer .meta-links a {
  color: var(--accent);
}

@media (max-width: 760px) {
  :root {
    --width: min(100% - 32px, 1024px);
  }

  .now {
    gap: 3px 16px;
  }

  .section {
    margin-top: 34px;
  }
}

/* Static site additions */
.index-page {
  padding-top: 38px;
}

.empty {
  margin: 0;
  padding: 22px 0;
  color: var(--muted);
}

.project-summary {
  max-width: 72ch;
  margin: 22px 0 0;
  color: var(--muted);
  line-height: 1.9;
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 14px;
  font-size: 13px;
}

.project-links a {
  color: var(--accent);
}

.project-links a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding-top: 4px;
}

.tag-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.tag-chip:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.tag-chip small {
  color: var(--faint);
  font-size: 10px;
}

@media (max-width: 760px) {
  .article-container {
    width: min(100% - 32px, 72ch);
  }
}

/* Homepage profile: compact, content first */
.profile {
  padding: 34px 0 22px;
  border-bottom: 1px solid var(--border);
}

.profile h1 {
  margin: 0;
  font-size: clamp(26px, 3.2vw, 36px);
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.profile .role {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.7;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.8;
}

.profile-meta b {
  margin-right: 7px;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

.profile-meta a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.profile-meta .sep {
  color: var(--faint);
}

/* Reading rhythm */
.writing li {
  grid-template-columns: 9.5ch minmax(0, 1fr);
  gap: 18px;
  padding: 10px 0;
}

.writing time {
  font-size: 11.5px;
}

.writing .title {
  font-size: 15px;
  line-height: 1.55;
}

.writing .desc {
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.75;
}

.section {
  margin-top: 36px;
}

.section-head {
  padding-bottom: 8px;
}

.section-head h1,
.section-head h2 {
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.projects th {
  font-size: 10.5px;
}

.projects td {
  font-size: 12.5px;
}

.prose {
  font-size: 15px;
  line-height: 1.95;
}

.article-header .lead {
  font-size: 15px;
}

@media (max-width: 640px) {
  .profile {
    padding-top: 28px;
  }

  .profile-meta {
    gap: 3px 16px;
  }

  .writing li {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

/* Learning map: same container/section rhythm as index pages. */
.map-page .map-lead {
  max-width: 72ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.9;
}

.map-page .map-body {
  width: 100%;
  max-width: none;
  padding-top: 26px;
}

.map-page .map-body pre {
  padding: 14px 0 16px;
  border: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: transparent;
  font-size: 11px;
  line-height: 1.5;
}

@media (max-width: 780px) {
  .map-page .map-body pre {
    font-size: 10px;
    line-height: 1.45;
  }
}

/* Learning map colors: 3 lane groups + neutral status colors. */
:root {
  --map-tech: #2563eb;
  --map-academic: #ca8a04;
}

@media (prefers-color-scheme: dark) {
  :root {
    --map-tech: #7aa2f7;
    --map-academic: #e0af68;
  }
}

.learning-map .map-axis {
  color: var(--muted);
}

.learning-map .map-lane {
  font-weight: 700;
}

/* 技术基础：编程、系统、AI、数据库 */
.learning-map .map-lane-programming,
.learning-map .map-lane-systems,
.learning-map .map-lane-ai,
.learning-map .map-lane-db {
  color: var(--map-tech);
}

/* 工程与实践：工程、项目 */
.learning-map .map-lane-engineering,
.learning-map .map-lane-project {
  color: var(--accent);
}

/* 升学与通识：软考、升学、通识 */
.learning-map .map-lane-academic {
  color: var(--map-academic);
}

.learning-map .map-bar {
  font-weight: 700;
}

/* 状态：只留进行中的强调色，结束和近似用中性灰 */
.learning-map .map-ended {
  color: var(--faint);
}

.learning-map .map-ongoing {
  color: var(--accent);
}

.learning-map .map-approx {
  color: var(--muted);
}

/* CV: A4-like sheet for screen and print. */
.cv-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 34px 16px 64px;
}

.cv-sheet {
  width: min(210mm, 100%);
  min-height: 297mm;
  padding: 18mm 20mm;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
}

.cv-header {
  margin: 0 0 8mm;
  padding-bottom: 5mm;
  border-bottom: 1px solid var(--border);
}

.cv-header h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.03em;
}

.cv-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.cv-prose {
  width: 100%;
  max-width: none;
  padding-top: 0;
  font-size: 14px;
  line-height: 1.85;
}

.cv-prose h2 {
  margin: 1.5em 0 0.5em;
  font-size: 16px;
}

.cv-prose h3 {
  margin: 1.1em 0 0.35em;
  font-size: 14px;
}

.cv-prose ul {
  margin-bottom: 1em;
}

.cv-hint {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
}

@media (max-width: 900px) {
  .cv-page {
    padding: 16px 10px 44px;
  }

  .cv-sheet {
    width: 100%;
    min-height: auto;
    padding: 18px 16px;
    border: 0;
    box-shadow: none;
  }
}

@page {
  size: A4;
  margin: 14mm;
}

@media print {
  body {
    background: #fff;
  }

  .site-header,
  .footer,
  .cv-hint {
    display: none !important;
  }

  .cv-page {
    display: block;
    padding: 0;
  }

  .cv-sheet {
    width: 100%;
    min-height: auto;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: #fff;
  }

  .cv-prose a {
    color: inherit;
    text-decoration: none;
  }
}
