/* =============================================================
   现代留白 · 全局样式覆盖
   仅通过主题 inject.head_end 加载，不修改主题源码。
   常改的部分：主色 --hue/--sat/--light、阅读宽度、留白变量。
   ============================================================= */

:root {
  /* 字体：中文优先系统字体，避免花哨字形 */
  --wb-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;

  /* 低饱和蓝灰主色：主题的 --theme / --theme-aN 均由这三个分量派生 */
  --hue: 214deg;
  --sat: 34%;
  --light: 42%;
  --accent: hsl(24 58% 46%);
  --link: hsl(214 45% 40%);
  --link-a20: hsl(214 45% 40% / 0.2);

  /* 留白与阅读宽度 */
  --fs-root: 16px;
  --width-main-article: 780px;
  --gap-base: 20px;
  --gap-page: 22px;
  --gap-p: 1.9em;
}

/* ---------- 亮色 ---------- */
:root:not([data-theme]),
:root[data-theme="light"] {
  --background: #f6f7f9;
  --card: #ffffff;
  --block: rgba(30, 41, 59, 0.045);
  --block-border: rgba(30, 41, 59, 0.09);
  --text-p0: #1f2733;
  --text-p1: rgba(31, 39, 51, 0.84);
  --text-p2: rgba(31, 39, 51, 0.7);
  --text-p3: rgba(31, 39, 51, 0.5);
  --text-p4: rgba(31, 39, 51, 0.38);
  --text-meta: rgba(31, 39, 51, 0.24);
}

/* ---------- 暗色（跟随系统） ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --background: #11151b;
    --card: #191e26;
    --block: rgba(226, 232, 240, 0.06);
    --block-border: rgba(226, 232, 240, 0.11);
    --text-p0: #e8edf4;
    --text-p1: rgba(232, 237, 244, 0.84);
    --text-p2: rgba(232, 237, 244, 0.7);
    --text-p3: rgba(232, 237, 244, 0.5);
    --text-p4: rgba(232, 237, 244, 0.38);
    --text-meta: rgba(232, 237, 244, 0.24);
  }
}

/* ---------- 暗色（手动切换） ---------- */
:root[data-theme="dark"] {
  --background: #11151b;
  --card: #191e26;
  --block: rgba(226, 232, 240, 0.06);
  --block-border: rgba(226, 232, 240, 0.11);
  --text-p0: #e8edf4;
  --text-p1: rgba(232, 237, 244, 0.84);
  --text-p2: rgba(232, 237, 244, 0.7);
  --text-p3: rgba(232, 237, 244, 0.5);
  --text-p4: rgba(232, 237, 244, 0.38);
  --text-meta: rgba(232, 237, 244, 0.24);
}

/* ---------- 排版 ---------- */
html {
  scroll-behavior: smooth;
}

body,
h1, h2, h3, h4, h5, h6,
button, input, textarea, select {
  font-family: var(--wb-font-sans) !important;
}

body {
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.4;
}

.md-text p,
.md-text li {
  line-height: 1.9;
}

a {
  text-decoration: none;
}

a:hover {
  color: var(--link);
}

/* ---------- 侧栏：去毛玻璃与渐变，干净的实体底色 ---------- */
.site-region--leftbar {
  background-image: none !important;
  background-color: var(--card) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-right: 1px solid var(--block-border);
}

/* ---------- 卡片：轻阴影 + 细边框 ---------- */
.post-card,
.widget-instance,
.card,
.tag-plugin.grid[bg='card'] > .cell {
  border: 1px solid var(--block-border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03),
    0 8px 24px rgba(16, 24, 40, 0.045);
}

/* ---------- 正文引用块：用于原帖信息等元数据 ---------- */
.md-text blockquote {
  border-left: 3px solid var(--theme);
  background: var(--block);
  border-radius: 0 10px 10px 0;
  padding: 12px 18px;
}

/* ---------- 表格：归档索引与参数表 ---------- */
.md-text table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--block-border);
  border-radius: 10px;
  overflow: hidden;
}

.md-text th,
.md-text td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--block-border);
}

.md-text th {
  background: var(--block);
  font-weight: 600;
  white-space: nowrap;
}

.md-text tr:last-child td {
  border-bottom: 0;
}

.md-text tbody tr:hover td {
  background: var(--block);
}

/* ---------- 图片：统一圆角，不改圆形头像 ---------- */
.md-text img:not([class*='avatar']):not(.emoji) {
  border-radius: 10px;
}

/* ---------- 渐变按钮改为纯色 ---------- */
a.button.start.gradient,
.button.gradient {
  background-image: none !important;
  background-color: var(--theme) !important;
}

/* ---------- 细滚动条 ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--text-meta) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--text-meta);
  border-radius: 8px;
}

/* ---------- 移动端收紧留白 ---------- */
@media screen and (max-width: 667px) {
  :root {
    --gap-page: 14px;
    --gap-base: 14px;
  }

  .post-card,
  .widget-instance,
  .card {
    border-radius: 12px;
  }
}
