/* 公共站主题、页首和页尾。
 * 公共断点：小于 1024px 折叠导航，960px 及以下调整平板布局，720px 及以下调整手机布局。
 */

:root {
  /* 品牌色 */
  --ink: #28241e;          /* 松烟墨：正文主色 */
  --ink-soft: #3a342c;     /* 淡墨：次要深色 */
  --tea-gold: #715631;     /* 茶金：主强调色 */
  --tea-gold-soft: #c8bca7;/* 沉茶：次要装饰 */
  --moon-white: #f3ecdc;   /* 月白：暗模式主文字 */

  /* 全局 V4 宣纸色板 */
  --bg: #faf7ef;
  --bg-elevated: #fffdf7;
  --bg-soft: #f3ede0;
  --surface: #f6f0e4;
  --fg: #28241e;
  --fg-muted: #5e5649;
  --fg-soft: #635b4e;
  --border: #dcd2c0;
  --border-strong: #857459;
  /* 茶金强调色：在 --bg (#faf7ef) 与 --bg-soft (#f3ede0) 上对比度均 >5.5:1 */
  --accent: #715631;
  --accent-hover: #5c4526;
  --accent-on: #fffaf0;
  /* 松青操作色与朱砂高亮色 */
  --pine: #2c574c;
  --pine-hover: #22453c;
  --on-pine: #fffdf4;
  --cinnabar: #943d2e;
  --tint: #f6e6d8;
  --grain: rgba(152, 100, 29, 0.02);
  --link: #2c574c;
  --focus-ring: #715631;
  --shadow-sm: 0 1px 2px rgba(40, 36, 30, 0.05), 0 1px 3px rgba(40, 36, 30, 0.06);
  --shadow-md: 0 4px 8px rgba(40, 36, 30, 0.05), 0 10px 20px rgba(40, 36, 30, 0.07);
  --shadow-lg: 0 12px 24px rgba(40, 36, 30, 0.08), 0 24px 48px rgba(40, 36, 30, 0.10);
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;

  /* 字体栈：标题与长文用宋体，界面与元信息用无衬线 */
  --font-serif: Georgia, 'Songti SC', 'Noto Serif CJK SC', 'Noto Serif SC',
                'Source Han Serif SC', 'STSong', 'SimSun', serif;
  --font-sans: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei UI', 'Microsoft YaHei',
               'Noto Sans CJK SC', 'Noto Sans SC', 'Source Han Sans SC', system-ui, sans-serif;
  --font-mono: 'Cascadia Mono', Consolas, 'SFMono-Regular', Menlo, monospace;
  /* 让复选框、滚动条等原生控件跟随站内主题，而不是系统深浅色 */
  color-scheme: light;
}

/* 中文字体里的弯引号/撇号默认全角，英文片段改用比例宽度（Source Han / Noto CJK 的 pwid） */
:lang(en) { font-feature-settings: 'pwid'; }

[data-theme='dark'] {
  color-scheme: dark;
  --bg: #191915;
  --bg-elevated: #211f1b;
  --bg-soft: #26241f;
  --surface: #24241e;
  --fg: #f3ecdc;
  --fg-muted: #c6bdad;
  --fg-soft: #bcae99;
  --border: #4a443a;
  --border-strong: #958671;
  --accent: #dfbf85;
  --accent-hover: #ebd09e;
  --accent-on: #241e12;
  --pine: #85c4af;
  --pine-hover: #9bd2bf;
  --on-pine: #111c1a;
  --cinnabar: #f29a83;
  --tint: #393029;
  --grain: rgba(216, 195, 152, 0.016);
  --link: #85c4af;
  --focus-ring: #dfbf85;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }
input::placeholder, textarea::placeholder { color: var(--fg-muted); opacity: 1; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

:is(.site-header, .lp-header) {
  --header-pine: var(--pine);
  --header-pine-hover: var(--pine-hover);
  --header-pine-fg: var(--on-pine);
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 247, 239, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-strong);
  font-family: var(--font-sans);
}

[data-theme='dark'] :is(.site-header, .lp-header) {
  background: rgba(25, 25, 21, 0.94);
}

.header-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(12px, 2.2vw, 36px);
  max-width: 1372px;
  min-height: 62px;
  margin-inline: auto;
  padding: 8px clamp(14px, 2.7vw, 36px);
}

.header-brand,
.header-nav,
.header-menu,
.header-channels {
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.header-brand {
  flex: 0 0 auto;
  gap: 9px;
  width: max-content;
  color: var(--fg);
  text-decoration: none;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.header-brand img { flex: none; }
.header-brand span:lang(en) { font-style: italic; font-weight: 400; }
.header-brand .brand-secondary {
  color: var(--fg-muted);
  font-family: Georgia, var(--font-serif);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.header-brand .brand-secondary:lang(zh-CN) { font-family: var(--font-serif); font-weight: 700; }

.header-nav, .header-menu { flex: 1 0 auto; gap: 6px; }
.header-channels { gap: clamp(4px, 1.2vw, 18px); }
.header-nav a, .header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding-inline: 8px;
  border-radius: 3px;
  color: var(--fg-muted);
  font-size: 16px;
  line-height: 1.25;
  text-decoration: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.header-nav a:hover, .header-icon:hover {
  background: var(--bg-soft);
  color: var(--fg);
}
.header-nav a.active:not(.header-tool),
.header-nav a[aria-current="page"]:not(.header-tool) {
  color: var(--cinnabar);
  font-weight: 650;
  background: transparent;
  border-radius: 0;
  box-shadow: inset 0 -2px var(--cinnabar);
  text-decoration: none;
}

.header-nav svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-nav .header-search { margin-inline-start: auto; }
.header-nav .header-tool {
  min-height: 36px;
  padding-inline: 13px;
  border: 1px solid var(--header-pine);
  border-radius: 3px;
  font-weight: 600;
}
/* A single-character stamp identifies invitation-only tools. */
.header-tool::after, .tool-beta::after, .beta-key::before {
  content: '测';
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  width: 15px;
  height: 15px;
  flex: none;
  vertical-align: .12em;
  color: var(--cinnabar);
  background: var(--bg-elevated);
  border: 1px solid currentColor;
  border-radius: 3px;
  font: 600 11px/1 var(--font-sans);
  letter-spacing: normal;
}
.header-tool::after, .tool-beta::after { content: '测' / '邀请内测'; }
.header-tool:lang(en)::after, .tool-beta:lang(en)::after { content: '测' / 'Invitation-only beta'; }
.tool-beta::after { margin-inline-start: 3px; }
.beta-key::before { margin-inline-end: 3px; }
.header-nav .header-tool { gap: 3px; }
.header-nav .header-practice {
  color: var(--header-pine);
  background: var(--bg-elevated);
  margin-inline-start: 10px;
  position: relative;
}
.header-nav .header-practice:hover {
  background: var(--bg-soft);
  border-color: var(--header-pine-hover);
  color: var(--header-pine-hover);
}
.header-practice::before {
  content: '';
  position: absolute;
  inset-inline-start: -10px;
  height: 20px;
  border-inline-start: 1px solid var(--border-strong);
}
.header-nav .header-practice.active {
  background: var(--bg-soft);
  color: var(--cinnabar);
  border-color: var(--cinnabar);
  box-shadow: inset 0 -2px var(--cinnabar);
}
.header-nav .header-editor {
  background: var(--header-pine);
  color: var(--header-pine-fg);
  border-color: var(--header-pine);
}
.header-nav .header-editor:hover {
  background: var(--header-pine-hover);
  border-color: var(--header-pine-hover);
  color: var(--header-pine-fg);
}

.header-icon {
  display: none;
  width: 44px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}
.header-ready :is(.site-theme-toggle, .lp-theme-toggle) { display: inline-flex; }
.header-icon .icon-sun,
[data-theme='dark'] .header-icon .icon-moon { display: none; }
[data-theme='dark'] .header-icon .icon-sun { display: block; }

.editor-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--accent-on);
  border: 1px solid var(--accent);
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.editor-cta:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-on);
}

body.landing .editor-cta { color: var(--accent-on); }

.editor-cta:active { transform: translateY(1px); }

.editor-cta::after {
  content: "→";
  font-size: 1.05em;
  transition: transform 0.15s;
}

.editor-cta:hover::after { transform: translateX(3px); }

/* 页脚：第四轮的四栏书目式排版，字号按第五轮放大。
 * 平底色 + 1px 顶线；左列品牌与导语，右三列栏目链接；细线下一行友情链接。 */
:is(.site-footer, .lp-footer) {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 44px clamp(18px, 3vw, 36px) 32px;
  color: var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
}

.site-footer { margin-top: 80px; }

:is(.site-footer, .lp-footer) a {
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s;
}

:is(.site-footer, .lp-footer) a:hover { color: var(--accent); }

:is(.site-footer-inner, .lp-footer-inner) {
  max-width: 1300px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto repeat(3, minmax(0, 1fr));
  gap: 32px;
  align-items: start;
}

.footer-imprint {
  padding-inline-end: 20px;
  border-inline-end: 1px solid var(--border);
}

:is(.site-footer-brand, .lp-footer-brand) {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0.03em;
  color: var(--fg);
  margin-bottom: 12px;
}

:is(.site-footer-brand, .lp-footer-brand) img {
  width: 30px;
  height: 30px;
}

:is(.site-footer, .lp-footer) .footer-heading {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--fg);
  font-weight: 700;
  margin: 0 0 10px;
}

:is(.site-footer, .lp-footer) ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

:is(.site-footer, .lp-footer) li { margin: 0 0 6px; }

:is(.site-footer, .lp-footer) li a {
  display: inline-block;
  padding-block: 2px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--fg-muted);
}

:is(.site-footer-links, .lp-footer-links) {
  max-width: 1300px;
  margin: 28px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 22px;
  font-size: 15px;
}

:is(.site-footer-links, .lp-footer-links) .footer-links-label {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--fg);
  white-space: nowrap;
}

:is(.site-footer-links, .lp-footer-links) ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

:is(.site-footer-links, .lp-footer-links) li { margin: 0; }

:is(.site-footer-links, .lp-footer-links) a {
  color: var(--fg-muted);
  font-size: 15px;
}

:is(.site-footer-links, .lp-footer-links) a span { color: var(--fg-soft); }

:is(.site-footer-bottom, .lp-footer-bottom) {
  max-width: 1300px;
  margin: 20px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 24px;
  font-size: 15px;
  color: var(--fg-soft);
}

:is(.site-footer-langs, .lp-footer-langs) {
  display: flex;
  gap: 16px;
}

:is(.site-footer-langs, .lp-footer-langs) a { color: var(--fg-soft); }
:is(.site-footer-langs, .lp-footer-langs) a:hover { color: var(--accent); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-on);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 200;
}

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

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

@media (max-width: 1439px) {
  .header-brand .brand-secondary { display: none; }
}

@media (1120px <= width < 1440px) {
  .header-inner { gap: 14px; padding-inline: 18px; }
  .header-channels { gap: 6px; }
  .header-nav a { font-size: 15.5px; padding-inline: 6px; }
  .header-nav .header-tool { padding-inline: 10px; }
}

@media (1024px <= width < 1120px) {
  .header-inner { gap: 8px; padding-inline: 12px; }
  .header-menu, .header-nav { gap: 4px; }
  .header-channels { gap: 2px; }
  .header-nav a { font-size: 14px; padding-inline: 4px; }
  .header-nav .header-tool { padding-inline: 7px; }
}

@media (1024px <= width < 1280px) {
  .header-channels:lang(en) a { white-space: normal; text-align: center; max-inline-size: 7.3em; text-wrap: balance; }
}

@media (width < 1024px) {
  :is(.site-header, .lp-header):not(.header-ready) { position: static; }

  .header-inner { gap: 6px; }
  .header-nav { justify-content: flex-end; gap: 2px; }
  .header-nav > .header-language {
    min-width: 44px;
    padding-inline: 4px;
    font-size: 14px;
  }

  .header-menu {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    white-space: normal;
  }
  .header-channels { flex-direction: column; align-items: stretch; }
  .header-menu a { justify-content: flex-start; padding-inline: 12px; font-size: 16px; }
  .header-menu .header-search, .header-menu .header-practice, .header-menu .header-editor { margin-inline-start: 0; }
  .header-menu .header-tool { justify-content: center; margin-top: 4px; }
  .header-practice::before { display: none; }

  .header-ready .header-menu-toggle { display: inline-flex; }
  .header-ready .header-menu {
    display: none;
    position: absolute;
    z-index: 1;
    inset: 100% 0 auto;
    max-height: calc(100dvh - 68px);
    overflow: auto;
    padding: 12px 14px;
    background: var(--bg-elevated);
    border-block: 1px solid var(--border);
    box-shadow: var(--shadow-md);
  }
  .header-ready .header-menu.is-open { display: flex; }

  :is(.site-header, .lp-header):not(.header-ready) .header-inner {
    display: block;
  }
  :is(.site-header, .lp-header):not(.header-ready) .header-nav {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  :is(.site-header, .lp-header):not(.header-ready) .header-menu {
    flex: 0 0 100%;
    margin-block: 8px;
  }
}

@media (max-width: 375px) {
  .header-inner { padding-inline: 8px; }
  .header-brand { gap: 4px; font-size: 17px; }
  .header-brand img { width: 24px; height: 24px; }
  .header-nav > .header-language { max-width: 66px; white-space: normal; text-align: center; }
}

@media (max-width: 900px) {
  :is(.site-footer-inner, .lp-footer-inner) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 24px;
  }
  .footer-imprint {
    grid-column: 1 / -1;
    padding-inline-end: 0;
    padding-bottom: 18px;
    border-inline-end: 0;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 520px) {
  :is(.site-footer, .lp-footer) { padding: 36px 18px 28px; }
  :is(.site-footer, .lp-footer) li { margin-bottom: 0; }
  :is(.site-footer, .lp-footer) li a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  :is(.site-footer-links, .lp-footer-links) li a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  :is(.site-footer-bottom, .lp-footer-bottom) {
    flex-direction: column;
    align-items: flex-start;
  }
  :is(.site-footer-langs, .lp-footer-langs) a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
}

/* 公共分页组件：服务端仍输出全部条目，JS 只切换当前页的可见性。 */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.pager[hidden] { display: none; }
.pager-page,
.pager-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--fg);
  font-size: 15px;
  line-height: 1;
  text-decoration: none;
}
.pager-page:hover,
.pager-step[href]:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-soft);
}
.pager-page[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-on);
  font-weight: 600;
}
.pager-step[aria-disabled="true"] {
  opacity: .45;
  cursor: default;
}
.pager-gap {
  min-width: 16px;
  color: var(--fg-muted);
  text-align: center;
}
.pager-status {
  margin: 8px 0 0;
  color: var(--fg-muted);
  font: 14px/1.55 var(--font-sans);
}
@media (max-width: 560px) {
  .pager { gap: 4px; }
  .pager-page,
  .pager-step {
    min-width: 34px;
    min-height: 38px;
    padding: 0 6px;
    font-size: 14px;
  }
}
