/* ============================================================
   拾光集 · 样式表（Astra 风格）
   ------------------------------------------------------------
   设计语言：纯白底 + 发丝线 + 小圆角 + 单一主色，无渐变、无毛玻璃
   零外部依赖：系统字体栈，无 CDN、无图标库
   主题：跟随系统 + 手动切换（localStorage key = blog_theme）
   顺序：令牌 → 基础 → 布局 → 顶栏 → Hero → 按钮 → 区块/卡片
         → 文章卡片 → 归档 → 输入框 → 文章详情 → 表格 → Toast
         → 页脚 → 响应式
   ============================================================ */

/* ---------- 设计令牌 ---------- */

:root {
  color-scheme: light;

  --bg: #ffffff;              /* 页面底色 */
  --bg-soft: #f7f9fc;         /* 区块 / 表头 / 输入框底色 */
  --bg-elevated: #ffffff;     /* 卡片底色 */

  --text: #334155;            /* 正文 */
  --text-strong: #16202f;     /* 标题 */
  --text-muted: #5a6675;      /* 次要文字（白底 5.9:1） */
  --text-faint: #68758a;      /* 元信息（白底 4.7:1，AA 达标） */

  --border: #e6e9ee;          /* 发丝线 */
  --border-strong: #cfd6df;   /* 控件描边 */

  --brand: #046bd2;           /* 主色（Astra 默认蓝） */
  --brand-strong: #0356a8;
  --brand-soft: #eaf3fd;
  --on-brand: #ffffff;        /* 主色底上的文字色 */
  --highlight: #eaf3fd;       /* 标题荧光笔底色 */
  --ring: rgba(4, 107, 210, .15);

  --code-bg: #f5f7fa;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 12px 28px rgba(15, 23, 42, .09);

  --radius-sm: 3px;
  --radius: 4px;
  --radius-lg: 6px;

  --maxw: 1180px;             /* 容器宽 */
  --content: 780px;           /* 正文栏宽 */
  --header-h: 76px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e1626;
  --bg-soft: #141d2f;
  --bg-elevated: #162034;

  --text: #c7d2e0;
  --text-strong: #f1f5f9;
  --text-muted: #9aa9bd;
  --text-faint: #8291a6;

  --border: #24304a;
  --border-strong: #33425f;

  --brand: #65a9f5;
  --brand-strong: #8dc0ff;
  --brand-soft: #16304f;
  --on-brand: #0b1220;        /* 浅蓝底必须用深色字，白字只有 2.4:1 */
  --highlight: rgba(101, 169, 245, .16);
  --ring: rgba(101, 169, 245, .22);

  --code-bg: #0b1322;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md: 0 14px 30px rgba(0, 0, 0, .55);
}

/* ---------- 基础 ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  margin: 0;
  color: var(--text-strong);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.01em;
}

p { margin: 0; }

a {
  color: var(--brand);
  text-decoration: none;
  transition: color .15s ease;
}
a:hover { color: var(--brand-strong); }

img { max-width: 100%; height: auto; }

code, pre, kbd { font-family: var(--mono); font-size: .9em; }

::selection { background: var(--brand-soft); color: var(--text-strong); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- 布局 ---------- */

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}
.page-top { padding-top: 48px; }
.page-narrow { max-width: var(--content); }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 14px; }
.hidden { display: none !important; }

.loading { padding: 48px 0; text-align: center; color: var(--text-faint); font-size: 14px; }

/* ---------- 顶栏 ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-strong);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.brand:hover { color: var(--brand); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--on-brand);
  font-size: 14px;
  font-weight: 700;
}

.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav a {
  position: relative;
  margin: 0 11px;
  padding: 6px 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}
.nav a::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--brand);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .18s ease;
}
.nav a:hover { color: var(--brand); }
.nav a:hover::after,
.nav a.active::after { transform: scaleX(1); }
.nav a.active { color: var(--brand); }

.nav a.cta {
  margin-left: 16px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 500;
}
.nav a.cta::after { content: none; }
.nav a.cta:hover { background: var(--brand-strong); color: var(--on-brand); }

/* 主题按钮：无边框的图标按钮，hover 才出淡底，避免和主按钮抢注意力 */
.theme-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: 12px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  /* 只放符号：优先用系统符号字体，Windows 上可确保 ☀︎/☽ 是单色而非彩色 emoji */
  font-family: "Segoe UI Symbol", "Apple Symbols", var(--font);
  font-variant-emoji: text;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.theme-btn:hover {
  border-color: var(--border);
  background: var(--bg-soft);
  color: var(--brand);
}

/* ---------- Hero ---------- */

.hero { padding: 64px 0 40px; }

.hero h1 {
  font-size: clamp(30px, 4.4vw, 50px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -.03em;
}
.hero h1 em {
  font-style: normal;
  color: var(--brand);
  background: linear-gradient(to top, var(--highlight) 34%, transparent 34%);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.hero .lead {
  max-width: 680px;
  margin-top: 20px;
  font-size: clamp(16px, 1.5vw, 18px);
  line-height: 1.8;
  color: var(--text-muted);
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 34px; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 26px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, color .15s ease,
              border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(.5px); }

.btn-primary { background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-strong); color: var(--on-brand); box-shadow: var(--shadow-md); }

.btn-ghost { background: var(--bg); color: var(--text-strong); border-color: var(--border-strong); }
.btn-ghost:hover { color: var(--brand); border-color: var(--brand); }

.btn-sm { padding: 8px 16px; font-size: 14px; }

/* ---------- 区块 / 卡片 ---------- */

.section { padding: 64px 0; }
.section + .section { border-top: 1px solid var(--border); }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.section-title h2 {
  font-size: clamp(21px, 2.4vw, 27px);
  font-weight: 600;
  letter-spacing: -.02em;
}
.section-title a { font-size: 14.5px; font-weight: 500; white-space: nowrap; }

.grid { display: grid; gap: 24px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid > .loading { grid-column: 1 / -1; }   /* 加载中/空状态占满整行，居中不跑偏 */

.card {
  padding: 26px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card-lg { padding: 32px; border-radius: var(--radius-lg); }
.card-title { margin-bottom: 8px; font-size: 17px; }
.card-sub { color: var(--text-muted); font-size: 14.5px; line-height: 1.75; }

.feature-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  font-size: 20px;
  line-height: 1;
}

/* ---------- 文章卡片 ---------- */

.post-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.post-card:hover {
  color: inherit;
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.post-card h3 {
  margin-bottom: 10px;
  font-size: 18px;
  line-height: 1.45;
  transition: color .15s ease;
}
.post-card:hover h3 { color: var(--brand); }

.post-card p {
  margin-bottom: 20px;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text-muted);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  font-size: 13px;
  color: var(--text-faint);
}

.post-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .01em;
}

/* ---------- 归档页 ---------- */

.archive-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}
.archive-bar .faint { margin-left: auto; }

/* ---------- 表单控件 ---------- */

input[type="text"],
input[type="search"],
input[type="password"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { resize: vertical; min-height: 90px; }

.search-input { flex: 0 1 340px; }

/* ---------- 文章详情 ---------- */

.article { max-width: var(--content); margin: 0 auto; }

.article-header {
  padding: 56px 0 24px;
  margin-bottom: 36px;
  border-bottom: 1px solid var(--border);
}
.article-header h1 {
  margin-bottom: 16px;
  font-size: clamp(26px, 3.6vw, 40px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.025em;
}
.article-header .post-meta { font-size: 13.5px; }

.article-body { font-size: 17px; line-height: 1.85; }

.article-body p { margin: 0 0 1.3em; }

.article-body h2 {
  margin: 2.1em 0 .65em;
  font-size: 25px;
  letter-spacing: -.02em;
}
.article-body h3 { margin: 1.9em 0 .55em; font-size: 20px; }
.article-body h4 { margin: 1.6em 0 .5em; font-size: 17.5px; }

.article-body ul,
.article-body ol { margin: 0 0 1.3em; padding-left: 1.4em; }
.article-body li { margin: .4em 0; }
.article-body li::marker { color: var(--text-faint); }

.article-body blockquote {
  margin: 1.6em 0;
  padding: 18px 22px;
  border-left: 3px solid var(--brand);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bg-soft);
  color: var(--text-muted);
}
.article-body blockquote p { margin-bottom: 0; }

.article-body hr {
  margin: 2.6em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.article-body img { margin: 1.4em 0; border-radius: var(--radius); }

.article-body a {
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}
.article-body a:hover { text-decoration-color: var(--brand); }

.article-body code {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  font-size: .88em;
}

.article-body pre {
  margin: 0 0 1.4em;
  padding: 18px 20px;
  overflow-x: auto;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
}
.article-body pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
}

.article-foot {
  max-width: var(--content);
  margin: 64px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* ---------- 表格（Markdown 渲染出的表格） ---------- */

.table-wrap {
  margin: 0 0 1.4em;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}
table.data th,
table.data td {
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data th {
  background: var(--bg-soft);
  color: var(--text-strong);
  font-weight: 600;
  white-space: nowrap;
}
table.data tr:last-child td { border-bottom: 0; }

/* ---------- Toast ---------- */

#toast-host {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 11px 20px;
  border-radius: var(--radius);
  background: var(--text-strong);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: toast-in .18s ease-out;
}
.toast.ok { background: #15803d; color: #fff; }
.toast.err { background: #b91c1c; color: #fff; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 页脚 ---------- */

.site-footer {
  margin-top: 88px;
  padding: 36px 0 44px;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
}
.site-footer .footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--brand); }

/* ---------- 内容页（关于） ---------- */

.page-title {
  margin-bottom: 20px;
  font-size: clamp(26px, 3.4vw, 36px);
  font-weight: 700;
  letter-spacing: -.025em;
}
.subheading { margin: 2.1em 0 .75em; font-size: 20px; }

.page-narrow p { margin: 0 0 1.15em; }
.page-narrow ul, .page-narrow ol { margin: 0 0 1.3em; padding-left: 1.4em; }
.page-narrow li { margin: .45em 0; }
.page-narrow li::marker { color: var(--text-faint); }
.page-narrow .grid { margin-top: 6px; }

/* 首页底部入口卡：文案在左，按钮在右 */
.card-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 28px;
}

/* ---------- 响应式 ---------- */

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding: 56px 0 40px; }
  .section { padding: 52px 0; }
}

@media (max-width: 760px) {
  :root { --header-h: 64px; }
  .container { padding: 0 18px; }
  .header-inner { gap: 12px; }
  .nav a { margin: 0 8px; font-size: 14.5px; }
  .nav a.hide-sm { display: none; }
  .nav a.cta { margin-left: 8px; padding: 8px 14px; font-size: 14px; }
  .theme-btn { margin-left: 6px; }
  .article-header { padding: 36px 0 20px; margin-bottom: 28px; }
  .article-body { font-size: 16.5px; }
}

@media (max-width: 680px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .hero { padding: 44px 0 32px; }
  .hero h1 { font-size: clamp(27px, 8.4vw, 36px); }
  .hero-actions { margin-top: 26px; }
  .section { padding: 44px 0; }
  .section-title { flex-direction: column; align-items: flex-start; gap: 8px; }
  .search-input { flex: 1 1 100%; }
  .archive-bar .faint { margin-left: 0; }
  .post-tags { margin-left: 0; }
  .article-foot { margin-top: 44px; }
  .site-footer { margin-top: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .post-card:hover { transform: none; }
}
