:root {
  color-scheme: light;
  /* 品牌色（ProductThinkingBranding.ai 03 画板） */
  --brand: #3f4cc4;
  --brand-deep: #1e3980;
  --brand-soft: #464ea3;
  --brand-sky: #aae2f0;
  /* 纸面与墨色：向品牌蓝做 2–3% 的偏冷，肉眼不可辨、气质上同族 */
  --paper: #f4f5f8;
  --paper-raised: #fafbfd;
  --ink: #43454c;
  --ink-soft: #54565e;
  --ink-faint: #7e818c;
  --rule: rgb(67 69 76 / 0.13);
  --glass: rgb(244 245 248 / 0.94);
  --code-bg: #eaecf1;
  --code-ink: #33353c;
  --note-bg: color-mix(in srgb, var(--brand-sky) 26%, #ffffff);
  --link: var(--brand);
  --by-invert: invert(1);
  --measure: 43.125rem;
  --wide: 58rem;
  /* 表达层：每篇文章注入自己的 --g1/--g2，仅用于 topbar 渐变 */
  --g1: #d8c783;
  --g2: #8d9a91;
  /* 结构层强调色：恒定品牌蓝（不再随文章渐变漂移） */
  --accent: var(--brand);
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", "Droid Sans Fallback", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a {
  color: inherit;
  text-decoration-thickness: from-font;
  text-underline-position: from-font;
  text-underline-offset: 0.18em;
  text-decoration-skip-ink: auto;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 4px;
}

::selection {
  background: color-mix(in srgb, var(--brand-sky), transparent 45%);
  color: var(--ink);
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper-raised);
  color: var(--ink);
  font-size: 0.82rem;
  transform: translateY(-150%);
  transition: transform 120ms ease-out;
}

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

.topbar {
  /* 表达层：每篇文章自己的渐变签名（模板注入 --g1/--g2） */
  height: 3px;
  background: linear-gradient(90deg, var(--g1), var(--g2));
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 0.7rem max(1.25rem, calc((100vw - var(--wide)) / 2));
  border-bottom: 1px solid var(--rule);
  background: var(--glass);
  backdrop-filter: blur(12px);
}

.masthead .brand {
  flex: 0 0 auto;
  display: block;
  width: 7.4rem;
}

.masthead .brand img {
  width: 100%;
  height: auto;
}

.masthead .brand .logo-on-dark,
.masthead .brand .mark-on-light,
.masthead .brand .mark-on-dark { display: none; }

.masthead nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.masthead nav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 0 0.75rem;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 120ms ease-out;
}

.masthead nav a:hover,
.masthead nav a[aria-current="page"] {
  color: var(--link);
}

main {
  display: block;
}

.hero {
  width: min(var(--wide), calc(100% - 2.5rem));
  margin: clamp(2rem, 5vw, 4rem) auto 0;
}

.hero img {
  width: 100%;
  aspect-ratio: 2 / 1;
  border-radius: 8px;
  object-fit: cover;
  object-position: top center;
  outline: 1px solid oklch(0 0 0 / 0.1);
  outline-offset: -1px;
}

h1,
.lead,
.byline,
article,
.list-page .listing {
  width: min(var(--measure), calc(100% - 2.5rem));
  margin-inline: auto;
}

h1 {
  margin-top: clamp(2.4rem, 6vw, 4.5rem);
  font-size: clamp(2rem, 4.2vw, 2.55rem);
  font-weight: 700;
  line-height: 1.24;
  letter-spacing: -0.025em;
}

.byline {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  color: var(--ink-faint);
  font-size: 0.82rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.byline .dot {
  opacity: 0.45;
}

.lead {
  margin-top: 2rem;
  padding-left: 1.15rem;
  border-left: 2px solid var(--accent);
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.8;
}

article {
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.95;
  padding-bottom: clamp(4rem, 10vw, 7rem);
}

article > * {
  margin-top: 1.45rem;
}

article p {
  overflow-wrap: break-word;
  text-align: start;
}

article a {
  overflow-wrap: anywhere;
  word-break: break-word;
  text-decoration-color: color-mix(in srgb, var(--link), transparent 55%);
  transition: color 120ms ease-out, text-decoration-color 120ms ease-out;
}

article a:hover {
  color: var(--link);
  text-decoration-color: var(--brand);
}

article strong {
  color: var(--ink);
  font-weight: 650;
}

article h2 {
  margin-top: clamp(3.5rem, 9vw, 5.5rem);
  font-size: clamp(1.4rem, 3vw, 1.65rem);
  font-weight: 700;
  line-height: 1.42;
  letter-spacing: -0.015em;
}

article h2 .num {
  display: inline-block;
  min-width: 2rem;
  margin-right: 0.6rem;
  color: var(--accent);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  vertical-align: 0.08em;
}

article ul,
article ol {
  padding-left: 1.4rem;
}

article li {
  padding-left: 0.3rem;
}

article li + li {
  margin-top: 0.55rem;
}

article li::marker {
  color: var(--accent);
}

blockquote {
  padding: 1.35rem 1.5rem;
  border-left: 2px solid var(--ink-faint);
  background: rgb(38 37 34 / 0.035);
  color: var(--ink-soft);
  font-size: 1.02rem;
}

blockquote p + p {
  margin-top: 1rem;
}

.note {
  display: flex;
  gap: 0.9rem;
  padding: 1.2rem 1.35rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--note-bg);
}

.note-icon {
  flex: 0 0 auto;
  font-size: 1rem;
  line-height: 1.8;
}

.note-body {
  min-width: 0;
}

.note-body p + p {
  margin-top: 0.9rem;
}

.archive-notice {
  margin-top: 2.5rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper-raised);
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.code {
  overflow-x: auto;
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  tab-size: 2;
}

.table-wrap {
  overflow-x: auto;
  border-block: 1px solid var(--rule);
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  line-height: 1.65;
}

.table-wrap th,
.table-wrap td {
  min-width: 8rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--rule);
  text-align: start;
  vertical-align: top;
}

.table-wrap th {
  background: rgb(38 37 34 / 0.035);
  color: var(--ink);
  font-weight: 650;
  white-space: nowrap;
}

figure {
  margin-top: 2.25rem;
}

article figure img {
  width: 100%;
  border-radius: 6px;
  outline: 1px solid oklch(0 0 0 / 0.1);
  outline-offset: -1px;
}

figcaption {
  margin-top: 0.65rem;
  color: var(--ink-faint);
  font-size: 0.76rem;
  line-height: 1.55;
  text-align: center;
}

.compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2.25rem;
}

.compare figure {
  margin-top: 0;
}

.pull {
  margin-block: 3rem;
  padding: 1.6rem clamp(0.5rem, 4vw, 2rem);
  border-block: 1px solid var(--rule);
  color: var(--ink);
  font-size: clamp(1.15rem, 2.8vw, 1.4rem);
  font-weight: 700;
  line-height: 1.7;
  text-align: center;
}

.related {
  margin-top: 4.5rem;
}

.related .related-title {
  margin: 0 0 0.8rem;
  padding: 0;
  border: 0;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.08em;
}

.related ul {
  padding: 0;
  list-style: none;
}

.related li {
  padding: 0;
}

.related li + li {
  margin-top: 0.65rem;
}

.related a,
.article-links a,
.listing a,
footer a {
  text-decoration-color: color-mix(in srgb, currentColor, transparent 66%);
  transition: color 120ms ease-out, text-decoration-color 120ms ease-out;
}

.related a:hover,
.article-links a:hover,
.listing a:hover,
footer a:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

.article-links {
  margin-top: 3rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.8rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.article-links .sep {
  opacity: 0.35;
}

.list-page {
  padding-bottom: clamp(4rem, 10vw, 7rem);
}

.list-page h1 {
  margin-top: clamp(3.5rem, 8vw, 6rem);
}

.list-page .lead {
  margin-bottom: 3.5rem;
}

.listing h2 {
  margin-top: 3.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
}

.listing ul {
  margin-top: 0.35rem;
  padding: 0;
  list-style: none;
}

.listing li {
  display: grid;
  grid-template-columns: 7.25rem minmax(0, 1fr);
  gap: 1rem;
  align-items: baseline;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgb(72 72 70 / 0.045);
}

.listing li time {
  color: var(--ink-faint);
  font-size: 0.72rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.listing li a {
  line-height: 1.55;
  text-decoration: none;
}

.listing li a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.topic-cloud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0;
  margin-top: 0.5rem;
}

.topic-cloud a {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid rgb(72 72 70 / 0.045);
  color: var(--ink-soft);
  font-size: 0.82rem;
  text-decoration: none;
}

.topic-cloud a:hover {
  background: rgb(38 37 34 / 0.035);
  color: var(--ink);
}

.topic-cloud .count {
  color: var(--ink-faint);
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
}

.year-index {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin-top: 2.5rem;
  padding-block: 0.85rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.year-index a {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

footer {
  padding: 3rem 1.25rem 4rem;
  color: var(--ink-faint);
  font-size: 0.78rem;
  text-align: center;
}

footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem 1.1rem;
  margin-bottom: 1rem;
}

footer nav a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.byfonter {
  display: inline-block;
  margin-bottom: 1.2rem;
  opacity: 0.66;
  transition: opacity 120ms ease-out;
}

.byfonter:hover {
  opacity: 1;
}

.byfonter img {
  width: 7rem;
  height: auto;
  filter: var(--by-invert);
}

.origin {
  margin-top: 0.4rem;
  font-size: 0.72rem;
}

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

@media (max-width: 680px) {
  body {
    font-size: 17px;
    line-height: 1.8;
  }

  .masthead {
    min-height: 64px;
    gap: 0.5rem;
    padding-inline: 1rem;
  }

  .masthead .brand {
    width: 6.7rem;
  }

  .masthead nav {
    gap: 0;
    font-size: 0.72rem;
  }

  .masthead nav a {
    padding-inline: 0.5rem;
  }

  .masthead nav a:last-child {
    display: none;
  }

  .hero {
    width: calc(100% - 2rem);
    margin-top: 1.5rem;
  }

  .hero img {
    aspect-ratio: 4 / 3;
    border-radius: 6px;
  }

  h1,
  .lead,
  .byline,
  article,
  .list-page .listing {
    width: calc(100% - 2.5rem);
  }

  h1 {
    margin-top: 2.35rem;
    font-size: clamp(1.85rem, 8.5vw, 2.35rem);
    line-height: 1.26;
  }

  .lead {
    margin-top: 1.6rem;
    padding-left: 0.9rem;
    font-size: 0.96rem;
    line-height: 1.78;
  }

  article > * {
    margin-top: 1.3rem;
  }

  article h2 {
    margin-top: 3.5rem;
    font-size: 1.4rem;
  }

  article {
    font-size: 1rem;
    line-height: 1.9;
  }

  article h2 .num {
    min-width: 1.9rem;
    margin-right: 0.45rem;
  }

  .compare {
    grid-template-columns: 1fr;
  }

  .note,
  blockquote {
    padding: 1.1rem 1.15rem;
  }

  .list-page h1 {
    margin-top: 3rem;
  }

  .list-page .lead {
    margin-bottom: 2.75rem;
  }

  .listing h2 {
    margin-top: 3rem;
  }

  .listing li {
    grid-template-columns: 6.1rem minmax(0, 1fr);
    gap: 0.7rem;
    padding-block: 0.7rem;
  }

  .topic-cloud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topic-cloud a {
    padding-inline: 0.55rem;
  }
}

@media (max-width: 360px) {
  .masthead nav a:first-child {
    display: none;
  }

  .listing li {
    grid-template-columns: 5.5rem minmax(0, 1fr);
  }

  .listing li time {
    font-size: 0.64rem;
  }
}

@media print {
  :root {
    --paper: #fff;
    --paper-raised: #fff;
  }

  body {
    color: #000;
    font-size: 11pt;
  }

  .topbar,
  .masthead nav,
  .article-links,
  .related,
  footer {
    display: none !important;
  }

  .masthead {
    position: static;
    border: 0;
    background: #fff;
  }

  .masthead .brand img,
  .byfonter img {
    filter: var(--by-invert);
  }

  .hero img {
    max-height: 35vh;
  }

  article,
  h1,
  .lead,
  .byline {
    width: 100%;
  }

  article a::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* ============ 深色主题 ============
   默认跟随系统；用户点过切换按钮后由 html[data-theme] 显式接管 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  color-scheme: dark;
  --paper: #16171c;
  --paper-raised: #1d1f26;
  --ink: #d8dae1;
  --ink-soft: #b7bac4;
  --ink-faint: #878b97;
  --rule: rgb(216 218 225 / 0.14);
  --glass: rgb(22 23 28 / 0.92);
  --code-bg: #101116;
  --code-ink: #c6c9d2;
  --note-bg: color-mix(in srgb, var(--brand-deep) 38%, #16171c);
  --link: #8f9af0;
  --accent: #8f9af0;
  --by-invert: none;
  }
  :root:not([data-theme="light"]) :is(blockquote) { background: rgb(216 218 225 / 0.05); }
  :root:not([data-theme="light"]) .table-wrap th { background: rgb(216 218 225 / 0.05); color: var(--ink); }
  :root:not([data-theme="light"]) :is(.hero img, article figure img) { outline-color: oklch(1 0 0 / 0.1); }
  :root:not([data-theme="light"]) .masthead .brand .logo-on-light { display: none; }
  :root:not([data-theme="light"]) .masthead .brand .logo-on-dark { display: block; }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #16171c;
  --paper-raised: #1d1f26;
  --ink: #d8dae1;
  --ink-soft: #b7bac4;
  --ink-faint: #878b97;
  --rule: rgb(216 218 225 / 0.14);
  --glass: rgb(22 23 28 / 0.92);
  --code-bg: #101116;
  --code-ink: #c6c9d2;
  --note-bg: color-mix(in srgb, var(--brand-deep) 38%, #16171c);
  --link: #8f9af0;
  --accent: #8f9af0;
  --by-invert: none;
}
[data-theme="dark"] :is(blockquote) { background: rgb(216 218 225 / 0.05); }
[data-theme="dark"] .table-wrap th { background: rgb(216 218 225 / 0.05); color: var(--ink); }
[data-theme="dark"] :is(.hero img, article figure img) { outline-color: oklch(1 0 0 / 0.1); }
[data-theme="dark"] .masthead .brand .logo-on-light { display: none; }
[data-theme="dark"] .masthead .brand .logo-on-dark { display: block; }

/* ---------- 主题切换按钮（lucide sun/moon） ---------- */
.theme-toggle {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 120ms ease-out;
}
.theme-toggle:hover { color: var(--link); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .i-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}
[data-theme="dark"] .theme-toggle .i-sun { display: block; }
[data-theme="dark"] .theme-toggle .i-moon { display: none; }


/* 窄屏：导航收紧但绝不换行（换行会把头部撑高，与图谱页不齐） */
@media (max-width: 640px) {
  /* 图标化后 space-between 会在中段留出大空洞：改为导航贴左、切换钮贴右 */
  .masthead { gap: 0.6rem; }
  .masthead nav { flex: 1; font-size: 0.74rem; gap: 0; }
  .masthead nav .theme-toggle { margin-left: auto; }
  .masthead nav a { padding: 0 0.45rem; }
  /* 窄屏只留宇航员图标 */
  .masthead .brand { width: 2.3rem; }
  .masthead .brand .logo-on-light, .masthead .brand .logo-on-dark { display: none !important; }
  .masthead .brand .mark-on-light { display: block; }
  [data-theme="dark"] .masthead .brand .mark-on-light { display: none; }
  [data-theme="dark"] .masthead .brand .mark-on-dark { display: block; }
}
@media (max-width: 640px) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .masthead .brand .mark-on-light { display: none; }
  :root:not([data-theme="light"]) .masthead .brand .mark-on-dark { display: block; }
}
