/* ==========================================================================
   itingyu.github.io · 主样式
   v3（2026-09-26 北京时间 · admin「页面比较丑」反馈）
   主题：浅 / 深双主题（系统跟随 + 手动切换 + localStorage 持久化）
   规范：WCAG 2.1 AA / 流体排版 / 双字体族（衬线大标题 + 无衬线正文）
   ========================================================================== */

:root {
  /* 排版尺度 */
  --step--1: clamp(0.85rem, 0.81rem + 0.20vw, 0.96rem);
  --step-0:  clamp(1.00rem, 0.95rem + 0.25vw, 1.13rem);
  --step-1:  clamp(1.18rem, 1.10rem + 0.38vw, 1.32rem);
  --step-2:  clamp(1.40rem, 1.28rem + 0.59vw, 1.58rem);
  --step-3:  clamp(1.95rem, 1.70rem + 1.20vw, 2.40rem);
  --step-4:  clamp(2.60rem, 2.10rem + 2.40vw, 3.60rem);
  --step-5:  clamp(3.20rem, 2.40rem + 3.80vw, 4.80rem);
  --line:    1.7;

  /* 字体族 */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-serif: ui-serif, Charter, "Iowan Old Style", "Apple Garamond",
    Baskerville, "Times New Roman", "Songti SC", "STSong", "Source Han Serif SC",
    serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono",
    Menlo, Consolas, "Liberation Mono", monospace;

  /* 浅色（默认） */
  --fg:           #1a1d24;
  --fg-muted:     #5b6370;
  --fg-faint:     #9aa3b0;
  --bg:           #fbfaf7;
  --bg-elev:      #ffffff;
  --bg-soft:      #f1efe9;
  --border:       #e6e3da;
  --border-soft:  #efece4;

  --accent:       #6d28d9;
  --accent-2:     #db2777;
  --accent-bg:    #f5edff;
  --code-bg:      #1a1d24;
  --code-fg:      #e6e3da;
  --selection:    #fde68a;

  /* 分类色（chip / accent by tag） */
  --tag-finance:    #b91c1c;
  --tag-finance-bg: #fee2e2;
  --tag-algorithm:  #1d4ed8;
  --tag-algorithm-bg: #dbeafe;
  --tag-note:       #6d28d9;
  --tag-note-bg:    #f5edff;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(26, 29, 36, .04), 0 1px 3px rgba(26, 29, 36, .06);
  --shadow-md: 0 4px 12px rgba(26, 29, 36, .06), 0 2px 4px rgba(26, 29, 36, .04);
  --shadow-lg: 0 12px 32px rgba(26, 29, 36, .10), 0 4px 8px rgba(26, 29, 36, .05);

  /* 半径 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fg:           #ece9e1;
    --fg-muted:     #a4a8b0;
    --fg-faint:     #6a6f78;
    --bg:           #0f1115;
    --bg-elev:      #161922;
    --bg-soft:      #1c1f2a;
    --border:       #2a2e3a;
    --border-soft:  #20232e;

    --accent:       #a78bfa;
    --accent-2:     #f472b6;
    --accent-bg:    #2e1065;
    --code-bg:      #0a0c12;
    --code-fg:      #ece9e1;
    --selection:    #facc15;

    --tag-finance:    #f87171;
    --tag-finance-bg: #3f1212;
    --tag-algorithm:  #60a5fa;
    --tag-algorithm-bg: #0c2a4a;
    --tag-note:       #c4b5fd;
    --tag-note-bg:    #2e1065;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .5), 0 2px 4px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6), 0 4px 8px rgba(0, 0, 0, .4);
  }
}

:root[data-theme="dark"] {
  --fg:           #ece9e1;
  --fg-muted:     #a4a8b0;
  --fg-faint:     #6a6f78;
  --bg:           #0f1115;
  --bg-elev:      #161922;
  --bg-soft:      #1c1f2a;
  --border:       #2a2e3a;
  --border-soft:  #20232e;

  --accent:       #a78bfa;
  --accent-2:     #f472b6;
  --accent-bg:    #2e1065;
  --code-bg:      #0a0c12;
  --code-fg:      #ece9e1;
  --selection:    #facc15;

  --tag-finance:    #f87171;
  --tag-finance-bg: #3f1212;
  --tag-algorithm:  #60a5fa;
  --tag-algorithm-bg: #0c2a4a;
  --tag-note:       #c4b5fd;
  --tag-note-bg:    #2e1065;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .5), 0 2px 4px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6), 0 4px 8px rgba(0, 0, 0, .4);
}

/* ---------- reset ---------- */

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: var(--line);
  color: var(--fg);
  background: var(--bg);
  transition: background-color .2s ease, color .2s ease;
  background-image:
    radial-gradient(at 12% 8%, color-mix(in srgb, var(--accent) 8%, transparent) 0px, transparent 50%),
    radial-gradient(at 92% 4%, color-mix(in srgb, var(--accent-2) 6%, transparent) 0px, transparent 50%);
  background-attachment: fixed;
  background-repeat: no-repeat;
}

::selection { background: var(--selection); color: var(--fg); }

a { color: var(--accent); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--accent-2); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }

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

hr {
  border: 0;
  border-top: 1px solid var(--border-soft);
  margin: 2.5rem 0;
}

/* ---------- skip link ---------- */

.skip-link {
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  position: fixed; left: 1rem; top: 1rem;
  width: auto; height: auto;
  padding: .5rem .75rem;
  background: var(--accent); color: #fff;
  border-radius: var(--r-sm); z-index: 999;
}

/* ---------- header / nav ---------- */

.site-header {
  border-bottom: 1px solid var(--border-soft);
  padding: .9rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  position: sticky; top: 0; z-index: 10;
}

.site-brand {
  display: flex; align-items: center; gap: .65rem;
  color: var(--fg); text-decoration: none;
  font-family: var(--font-serif);
  font-weight: 600; font-size: var(--step-1);
  letter-spacing: -.01em;
}
.site-brand:hover { text-decoration: none; color: var(--accent); }

.site-brand-mark {
  width: 1.8em; height: 1.8em; border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-sans);
  font-size: .75em; font-weight: 700;
  letter-spacing: -.02em;
  box-shadow: var(--shadow-sm);
}

.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; }
.site-nav a {
  color: var(--fg-muted);
  padding: .4rem .8rem; border-radius: 999px;
  font-size: var(--step--1); font-weight: 500;
  transition: all .15s ease;
}
.site-nav a:hover { color: var(--fg); background: var(--bg-soft); text-decoration: none; }
.site-nav a[aria-current="page"] {
  color: var(--fg); background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* 主题切换按钮 */
.theme-toggle {
  appearance: none; border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--fg-muted); cursor: pointer;
  width: 2.2rem; height: 2.2rem; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: .25rem;
  transition: all .15s ease;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--accent); transform: rotate(15deg); }
.theme-toggle svg { width: 1rem; height: 1rem; }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- container ---------- */

.container       { max-width: 920px; margin: 3rem auto; padding: 0 1.5rem; }
.container-wide  { max-width: 1080px; margin: 3rem auto; padding: 0 1.5rem; }

/* ---------- typography ---------- */

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  line-height: 1.18; margin: 2rem 0 .8rem;
  color: var(--fg);
  letter-spacing: -.015em;
  font-weight: 600;
}
h1 { font-size: var(--step-3); margin-top: 0; }
h2 { font-size: var(--step-2); margin-top: 2.5rem; }
h3 { font-size: var(--step-1); margin-top: 2rem; }
h4 { font-size: var(--step-0); font-weight: 600; }

p, ul, ol, blockquote, pre, table { margin: 0 0 1.2rem; }

blockquote {
  margin: 1.5rem 0; padding: 1rem 1.25rem;
  border-left: 3px solid var(--accent);
  color: var(--fg-muted);
  background: var(--bg-soft);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-style: italic;
  font-family: var(--font-serif);
}

ul, ol { padding-left: 1.5rem; }
li + li { margin-top: .35rem; }

code {
  font-family: var(--font-mono);
  font-size: .9em;
  background: var(--bg-soft); color: var(--accent);
  padding: .15em .4em; border-radius: var(--r-sm);
  font-weight: 500;
  border: 1px solid var(--border-soft);
}

pre {
  background: var(--code-bg); color: var(--code-fg);
  padding: 1.2rem 1.4rem; border-radius: var(--r-md);
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  font-size: var(--step--1);
  line-height: 1.65;
  box-shadow: var(--shadow-md);
}
pre code {
  background: transparent; color: inherit; padding: 0;
  border: 0; font-weight: 400;
}

table {
  width: 100%; border-collapse: collapse; font-size: var(--step--1);
  border: 1px solid var(--border-soft); border-radius: var(--r-md);
  overflow: hidden;
}
th, td {
  text-align: left; padding: .65rem .85rem;
  border-bottom: 1px solid var(--border-soft);
}
th { background: var(--bg-soft); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

/* ---------- post cards ---------- */

.post-list {
  list-style: none; padding: 0;
  display: grid; gap: 1.25rem;
  margin: 1.5rem 0;
}
.post-list > li {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 1.5rem 1.75rem;
  transition: all .2s ease;
  box-shadow: var(--shadow-sm);
}
.post-list > li:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.post-list .post-title {
  font-family: var(--font-serif);
  font-size: var(--step-2); font-weight: 600;
  margin: 0 0 .5rem; line-height: 1.25;
  letter-spacing: -.01em;
}
.post-list .post-title a { color: var(--fg); }
.post-list .post-title a:hover { color: var(--accent); text-decoration: none; }

.post-meta {
  display: flex; flex-wrap: wrap; gap: .35rem .85rem;
  color: var(--fg-muted); font-size: var(--step--1);
  align-items: center;
  margin-bottom: .35rem;
}
.post-meta time {
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.post-meta .dot { color: var(--fg-faint); }

.post-excerpt {
  color: var(--fg-muted);
  margin-top: .5rem;
  font-size: var(--step-0);
  line-height: 1.6;
}

/* ---------- tags / chips ---------- */

.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: var(--step--1); line-height: 1;
  padding: .3rem .65rem;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--fg-muted); background: var(--bg-elev);
  text-decoration: none;
  font-weight: 500;
  transition: all .15s ease;
}
.chip:hover {
  color: var(--accent); border-color: var(--accent);
  background: var(--accent-bg);
  text-decoration: none;
  transform: translateY(-1px);
}
.chip[aria-current="page"] {
  color: var(--accent); border-color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}

/* 分类色 chip（按 tag 名着色） */
.chip[data-tag="finance"]   { color: var(--tag-finance);   border-color: var(--tag-finance);   background: var(--tag-finance-bg); }
.chip[data-tag="algorithm"] { color: var(--tag-algorithm); border-color: var(--tag-algorithm); background: var(--tag-algorithm-bg); }
.chip[data-tag="note"]      { color: var(--tag-note);      border-color: var(--tag-note);      background: var(--tag-note-bg); }

.tag-row { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0 1.5rem; }

/* ---------- article (single post) ---------- */

.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-soft);
}
.article-header h1 {
  margin-bottom: .75rem;
  font-size: var(--step-4);
  line-height: 1.1;
}
.article-header .post-meta { margin-top: .75rem; font-size: var(--step-0); }
.article-header .post-excerpt {
  margin-top: 1rem; font-size: var(--step-1);
  color: var(--fg-muted);
  font-family: var(--font-serif);
  font-style: italic;
  line-height: 1.55;
}

.article-footer {
  margin-top: 4rem; padding-top: 2rem;
  border-top: 1px solid var(--border-soft);
  color: var(--fg-muted); font-size: var(--step--1);
}

.callout {
  margin: 1.5rem 0; padding: 1rem 1.25rem;
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: var(--step-0);
}
.callout-warn { border-left-color: #d97706; background: color-mix(in srgb, #d97706 6%, var(--bg-soft)); }
.callout-note { border-left-color: var(--accent); }

/* ---------- archive list (grouped by year-month) ---------- */

.archive-group {
  margin: 2rem 0;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow-sm);
}
.archive-group h3 {
  margin: 0 0 1rem;
  font-size: var(--step-1);
  color: var(--fg);
  font-weight: 600;
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: var(--step--1);
}
.archive-group ul { list-style: none; padding: 0; margin: 0; }
.archive-group li {
  display: grid; grid-template-columns: 5rem 1fr;
  gap: 1rem; padding: .55rem 0;
  border-bottom: 1px dotted var(--border-soft);
  align-items: baseline;
}
.archive-group li:last-child { border-bottom: 0; }
.archive-group li time {
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  font-size: var(--step--1);
  font-weight: 500;
}
.archive-group li a {
  color: var(--fg);
  transition: color .15s ease;
}
.archive-group li a:hover { color: var(--accent); }

/* ---------- home hero ---------- */

.hero {
  padding: 4rem 0 3rem;
  margin-bottom: 2rem;
  position: relative;
}
.hero-eyebrow {
  display: inline-block;
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 1rem;
  padding: .25rem .75rem;
  background: var(--accent-bg);
  border-radius: 999px;
}
.hero h1 {
  font-size: var(--step-5);
  letter-spacing: -.03em;
  margin: 0 0 1rem;
  line-height: 1.05;
  background: linear-gradient(135deg, var(--fg) 0%, var(--accent) 50%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.hero .lead {
  font-size: var(--step-2);
  color: var(--fg-muted);
  max-width: 30ch;
  font-family: var(--font-serif);
  font-style: italic;
  line-height: 1.4;
  margin: 0;
}
.hero-actions {
  display: flex; flex-wrap: wrap; gap: .75rem;
  margin-top: 2rem;
}
.hero-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .7rem 1.25rem;
  border-radius: 999px;
  font-size: var(--step-0);
  font-weight: 600;
  text-decoration: none;
  transition: all .2s ease;
  border: 1px solid transparent;
}
.hero-btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.hero-btn-primary:hover {
  background: var(--accent-2);
  color: #fff;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.hero-btn-ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
}
.hero-btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
}

.section-title {
  font-family: var(--font-sans);
  font-size: var(--step--1); color: var(--fg-muted);
  font-weight: 700; text-transform: uppercase;
  letter-spacing: .15em; margin: 2.5rem 0 1rem;
  display: flex; align-items: center; gap: .75rem;
}
.section-title::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--border-soft);
  padding: 2.5rem 1.5rem;
  margin-top: 4rem;
  color: var(--fg-muted);
  font-size: var(--step--1);
  text-align: center;
  background: var(--bg-soft);
}
.site-footer a {
  color: var(--fg-muted);
  font-weight: 500;
  transition: color .15s ease;
}
.site-footer a:hover { color: var(--accent); }
.site-footer .links {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: .4rem 1.25rem; margin-bottom: 1rem;
  font-size: var(--step-0);
}
.site-footer .copyright {
  font-size: var(--step--1);
  color: var(--fg-faint);
  margin-top: .5rem;
}

/* ---------- 404 ---------- */

.fourofour { text-align: center; padding: 6rem 1rem 4rem; }
.fourofour h1 {
  font-size: clamp(6rem, 20vw, 12rem);
  margin: 0;
  color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  line-height: 1;
}
.fourofour p { font-size: var(--step-1); color: var(--fg-muted); }

/* ---------- print ---------- */

@media print {
  .site-header, .site-footer, .theme-toggle, .skip-link,
  .hero-actions, .hero-eyebrow { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: #000; text-decoration: underline; }
  pre, blockquote { border: 1px solid #ccc; page-break-inside: avoid; }
  h2, h3 { page-break-after: avoid; }
  .post-list > li { box-shadow: none; border: 1px solid #ccc; }
}

/* ---------- prefers-reduced-motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .post-list > li:hover, .hero-btn:hover { transform: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .container, .container-wide { padding: 0 1.1rem; margin-top: 2rem; margin-bottom: 2rem; }
  .hero { padding: 2.5rem 0 1.5rem; }
  .post-list > li { padding: 1.2rem 1.25rem; }
  .archive-group { padding: 1.25rem; }
  .article-header h1 { font-size: var(--step-3); }
}

/* ---------- keyboard focus ring ---------- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

button:focus-visible,
.theme-toggle:focus-visible {
  outline-offset: 2px;
}

/* ==========================================================================
   AIWORK1-27 · 金融简报专用样式(render-finance-brief.js 输出)
   - .ticker         标的代码:等宽 + 加粗 + 浅底色
   - .delta-up/down  涨跌幅染色(WCAG AA,浅 / 深双主题都达标)
   - .brief-table    简报表格微调(数字右对齐、紧凑)
   ========================================================================== */

.ticker {
  font-family: var(--font-mono);
  font-size: .92em;
  font-weight: 600;
  padding: .05em .35em;
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--border-soft);
  letter-spacing: .02em;
}

.delta-up {
  font-family: var(--font-mono);
  font-size: .92em;
  font-weight: 600;
  color: #15803d;          /* 浅色:绿 WCAG AA on #fbfaf7 ≈ 4.85:1 */
  background: #dcfce7;
  padding: .05em .35em;
  border-radius: var(--r-sm);
  margin-left: .15em;
}

.delta-down {
  font-family: var(--font-mono);
  font-size: .92em;
  font-weight: 600;
  color: #b91c1c;          /* 浅色:红,与现有 --tag-finance 同色系 */
  background: #fee2e2;
  padding: .05em .35em;
  border-radius: var(--r-sm);
  margin-left: .15em;
}

:root[data-theme="dark"] .delta-up {
  color: #4ade80;          /* 深色:亮绿 ≈ 8.2:1 on #0f1115 */
  background: #14532d;
}

:root[data-theme="dark"] .delta-down {
  color: #f87171;          /* 深色:亮红 ≈ 6.5:1 on #0f1115 */
  background: #450a0a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .delta-up {
    color: #4ade80;
    background: #14532d;
  }
  :root:not([data-theme="light"]) .delta-down {
    color: #f87171;
    background: #450a0a;
  }
}

.brief-table {
  margin: 1.5rem 0;
  font-size: var(--step--1);
}
.brief-table th,
.brief-table td {
  vertical-align: baseline;
}
.brief-table td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.brief-table th:not(:first-child) {
  text-align: right;
}
.brief-table .ticker,
.brief-table .delta-up,
.brief-table .delta-down {
  font-size: .95em;
}

/* ==========================================================================
   v4 · 立竿见影批(2026-09-26)
   - .reading-progress 顶部阅读进度条
   - .toc 文章页右侧粘性目录
   - .post-cover 封面图(文章 + 列表)
   - .related 相关文章区
   ========================================================================== */

/* ---------- reading progress bar ---------- */

.reading-progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(to right, var(--accent), var(--accent-2));
  transform-origin: 0 50%;
  transform: scaleX(0);
  transition: transform .08s linear;
  z-index: 50;
  pointer-events: none;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--accent) 40%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .reading-progress { transition: none; }
}

/* ---------- table of contents ---------- */

.toc {
  position: sticky; top: 5rem;
  float: right;
  width: 16rem;
  margin: 0 -18rem 1.5rem 1.5rem;
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  font-size: var(--step--1);
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}
.toc-title {
  font-family: var(--font-sans);
  font-size: var(--step--1);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--fg-muted);
  margin: 0 0 .65rem;
}
.toc-list { list-style: none; padding: 0; margin: 0; }
.toc-list li { margin: 0; }
.toc-link {
  display: block;
  padding: .3rem .5rem;
  color: var(--fg-muted);
  text-decoration: none;
  border-radius: var(--r-sm);
  border-left: 2px solid transparent;
  transition: all .15s ease;
  line-height: 1.4;
}
.toc-link:hover { color: var(--fg); background: var(--bg-soft); }
.toc-link.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}
.toc-list .toc-sub { padding-left: 1rem; font-size: .92em; }

/* mobile: 折叠成顶部按钮 */
.toc-toggle {
  display: none;
}
@media (max-width: 1180px) {
  .toc {
    position: static; float: none;
    width: auto; margin: 1.5rem 0;
  }
  .toc-toggle {
    display: inline-flex; align-items: center; gap: .4rem;
    appearance: none; border: 1px solid var(--border); background: var(--bg-elev);
    color: var(--fg-muted); cursor: pointer;
    padding: .45rem .85rem; border-radius: 999px;
    font-size: var(--step--1); font-weight: 500;
    margin: 0 0 1rem;
    transition: all .15s ease;
  }
  .toc-toggle:hover { color: var(--fg); border-color: var(--accent); }
  .toc[data-collapsed="true"] .toc-list { display: none; }
  .toc[data-collapsed="true"] .toc-title::after { content: " ▸"; }
  .toc[data-collapsed="false"] .toc-title::after { content: " ▾"; }
}

/* ---------- post cover image ---------- */

.post-cover {
  display: block;
  width: 100%; max-width: 100%;
  height: auto;
  border-radius: var(--r-lg);
  margin: 0 0 1.5rem;
  box-shadow: var(--shadow-md);
  object-fit: cover;
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
}
.post-cover--list {
  aspect-ratio: 21 / 9;
  margin: 0 0 1rem;
}
.post-cover--home {
  aspect-ratio: 24 / 9;
  margin: 0 0 1.25rem;
}

/* ---------- related posts ---------- */

.related {
  margin: 3rem 0 0;
  padding-top: 2rem;
  border-top: 1px solid var(--border-soft);
}
.related-title {
  font-family: var(--font-sans);
  font-size: var(--step--1); color: var(--fg-muted);
  font-weight: 700; text-transform: uppercase;
  letter-spacing: .15em; margin: 0 0 1rem;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  list-style: none; padding: 0; margin: 0;
}
.related-card {
  display: block;
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  text-decoration: none;
  color: var(--fg);
  transition: all .2s ease;
}
.related-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.related-card .related-card-title {
  font-family: var(--font-serif);
  font-size: var(--step-0);
  font-weight: 600;
  margin: 0 0 .35rem;
  line-height: 1.3;
  letter-spacing: -.01em;
}
.related-card .related-card-meta {
  font-size: var(--step--1);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.related-card .related-card-excerpt {
  font-size: var(--step--1);
  color: var(--fg-muted);
  margin: .35rem 0 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.related-empty {
  color: var(--fg-muted);
  font-style: italic;
  font-size: var(--step--1);
}

/* ==========================================================================
   v5 · 搜索页样式(2026-09-26)
   - .search-box / .search-results / .search-hit
   ========================================================================== */

.search-hint {
  color: var(--fg-muted);
  font-size: var(--step--1);
  margin: 0 0 1.25rem;
}

.search-box {
  margin-bottom: 2rem;
}

.search-box input[type="search"] {
  display: block;
  width: 100%;
  padding: .9rem 1.1rem;
  font-size: var(--step-1);
  font-family: var(--font-sans);
  color: var(--fg);
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  transition: all .15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.search-box input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg), var(--shadow-sm);
}

.search-status {
  margin: .65rem 0 0;
  font-size: var(--step--1);
  color: var(--fg-muted);
}

.search-results {
  list-style: none;
  padding: 0; margin: 0;
}

.search-empty {
  padding: 1rem 0;
  color: var(--fg-muted);
  font-style: italic;
  font-size: var(--step--1);
}

.search-hit {
  padding: 1.25rem 1.4rem;
  margin: 0 0 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  transition: all .2s ease;
}
.search-hit:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.search-hit-title {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  font-weight: 600;
  margin: 0 0 .35rem;
  letter-spacing: -.01em;
  line-height: 1.3;
}
.search-hit-title a {
  color: var(--fg);
  text-decoration: none;
}
.search-hit-title a:hover { color: var(--accent); }

.search-hit-meta {
  font-size: var(--step--1);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  margin: 0 0 .5rem;
}

.chip-mini {
  display: inline-block;
  padding: .05em .5em;
  margin-right: .15em;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 999px;
  font-size: .92em;
  font-weight: 500;
}

.search-hit-excerpt {
  margin: 0;
  color: var(--fg-muted);
  font-size: var(--step--1);
  line-height: 1.6;
}

@media (max-width: 640px) {
  .search-hit { padding: 1rem 1.1rem; }
  .search-box input[type="search"] { font-size: var(--step-0); }
}
