/* ============================================================
 * style.css — 简约风格 · 明暗双主题 · 移动端竖屏优先
 * ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f4f4f1;
  --text: #1b1b1a;
  --text-2: #5d5d5a;
  --text-3: #8a8a85;
  --border: #e7e7e2;
  --border-2: #d9d9d3;
  --accent: #2f6f4f;
  --accent-ink: #ffffff;
  --accent-soft: #eaf2ed;
  /* 选中文本的底色。**不能与 --accent-soft 相同**：正文里的 .note 提示块
   * 就是 accent-soft 底色，一旦两者同色，在提示块里选中文字就完全看不出来
   * （用户实测踩到过）。这里单独用一个更深的绿，与提示块底色有明显明度差。 */
  --select-bg: #b0d7c2;
  --select-ink: #10241a;
  --danger: #a8443a;
  --shadow-sm: 0 1px 2px rgba(20, 20, 18, .05);
  --shadow-md: 0 1px 2px rgba(20, 20, 18, .04), 0 10px 28px rgba(20, 20, 18, .05);
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1180px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans JP", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", Menlo, monospace;
  --header-h: 60px;
}

[data-theme="dark"] {
  --bg: #0f100f;
  --surface: #171918;
  --surface-2: #1f2120;
  --text: #e8e9e7;
  --text-2: #a3a6a2;
  --text-3: #757874;
  --border: #272928;
  --border-2: #343735;
  --accent: #6fcf97;
  --accent-ink: #10241a;
  --accent-soft: #1a2620;
  --select-bg: #3a6b52;
  --select-ink: #ecf7f1;
  --danger: #e08a80;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .38);
}

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

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

/* 锚点落点让出吸顶栏的高度，否则目标标题会被顶栏盖住 */
:target, section[id], h2[id], #comments {
  scroll-margin-top: calc(var(--header-h) + 16px + env(safe-area-inset-top));
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  /* 原为 word-break: break-word —— 该值等价于 word-break:normal +
   * overflow-wrap:anywhere，会让纯文本也能在词内任意处断开（连数字+单位
   * 都被拆开）。改回 normal，换行只发生在正常断点。 */
  word-break: normal;
}

html.lang-pending body { visibility: hidden; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1, h2, h3, h4 { line-height: 1.35; font-weight: 650; margin: 0; letter-spacing: -.01em; }

button, input, textarea { font: inherit; color: inherit; }

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

::selection { background: var(--select-bg); color: var(--select-ink); }

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* 顶栏任何一项都不得撑破视口 */
.brand, .header-tools { min-width: 0; }
.header-tools { flex-shrink: 0; }

.brand {
  display: flex;
  flex-direction: column;
  margin-right: auto;
  min-width: 0;
  color: inherit;
}
.brand:hover { text-decoration: none; }
.brand-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; }
.brand-sub {
  font-size: .76rem;
  color: var(--text-3);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* 语言切换 */
.lang-switch {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.lang-switch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: .82rem;
  line-height: 1.4;
  min-height: 30px;
  transition: background .15s, color .15s;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* 主题切换 */
.icon-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .i-moon { display: none; }
[data-theme="dark"] .icon-btn .i-sun { display: none; }
[data-theme="dark"] .icon-btn .i-moon { display: block; }

/* ---------- 页面骨架 ---------- */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.layout {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  gap: 34px;
  align-items: start;
}

/* 网格子项默认 min-width:auto，会被内容撑破容器 → 必须归零 */
.layout > * { min-width: 0; }

/* ---------- 左侧分类 ---------- */
.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 20px);
}

.sidebar-title {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-3);
  font-weight: 700;
  margin-bottom: 10px;
  padding: 0 10px;
}

.catnav { display: flex; flex-direction: column; gap: 2px; }

.catnav button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .92rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .15s, color .15s;
}
.catnav button:hover { background: var(--surface-2); color: var(--text); }
.catnav button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

.catnav .count {
  margin-left: auto;
  font-size: .74rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- 内容区 ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.section-head h1 { font-size: 1.32rem; }
.section-head .muted { color: var(--text-3); font-size: .84rem; }

/* ---------- 排序下拉框 ---------- */
.sort-control {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
}
.sort-label {
  color: var(--text-3);
  font-size: .8rem;
  white-space: nowrap;
}
#sort-select {
  font-family: inherit;
  font-size: .82rem;
  line-height: 1.4;
  color: var(--text-2);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 28px 5px 10px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238a8a85' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5L8 10.5L12 6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px 14px;
  transition: border-color .15s, color .15s;
}
#sort-select:hover { border-color: var(--border-2); color: var(--text); }
#sort-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-theme="dark"] #sort-select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23757874' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5L8 10.5L12 6.5'/%3E%3C/svg%3E");
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  /* ★ 不拉伸卡片：有封面图的文章会比纯文字卡片高，
   *   若默认 stretch，无封面那张会被拉出大片空白。
   *   align-items:start 让每张卡片保持自身高度。 */
  align-items: start;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-2);
}
.card:focus-within { border-color: var(--accent); }

.card-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.card-body {
  padding: 16px 17px 17px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-title {
  font-size: 1.02rem;
  font-weight: 650;
  line-height: 1.45;
}
.card-title a { color: inherit; }
.card-title a::after { content: ""; position: absolute; inset: 0; }
.card:hover .card-title { color: var(--accent); }

.card-summary {
  color: var(--text-2);
  font-size: .9rem;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .76rem;
  color: var(--text-3);
  margin-top: 2px;
  flex-wrap: wrap;
}
.card-meta .tag {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}

.empty {
  color: var(--text-3);
  font-size: .93rem;
  padding: 40px 0;
  text-align: center;
}

/* 连字符标识符整体不折行（PSS-2005 / NI-VISA / arm64-v8a）。
 * 浏览器按 UAX#14 默认在连字符后给断点，「PSS-」会留在行尾、「2005」掉到下一行。
 * 实测 word-break:keep-all 与 hyphens:none 都拦不住（Chrome 仍按 HY 断点断行），
 * 只有整体 nowrap 才有效。 */
.nobr { white-space: nowrap; }

/* ---------- 文章详情 ---------- */
/* 详情页与首页共用 .wrap + .layout：左侧分类栏保留，正文列限宽便于阅读 */
.post-main {
  max-width: 760px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: .87rem;
  margin-bottom: 20px;
  min-height: 32px;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

.post-header { margin-bottom: 26px; }
.post-title { font-size: 1.75rem; margin-bottom: 12px; }
.post-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text-3);
  font-size: .8rem;
  flex-wrap: wrap;
}

.article {
  font-size: 1.02rem;
  line-height: 1.85;
  color: var(--text);
}
.article > * + * { margin-top: 1.15em; }
.article h2 {
  font-size: 1.2rem;
  margin-top: 2em;
  padding-top: .3em;
}
.article h3 { font-size: 1.05rem; margin-top: 1.7em; }
.article ul, .article ol { padding-left: 1.35em; }
.article li + li { margin-top: .45em; }
.article li::marker { color: var(--text-3); }
.article code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: .1em .38em;
  border-radius: 5px;
  /* 内联代码是标识符 / 命令 / 路径，不能在词内被拆开：
   * 原来的 break-all 会把 !CRASH 断成 !CRA/SH、把 --sim 断成 --/sim、
   * 把 PSS-2005 断在数字中间。white-space:nowrap 让内联代码整体不折行；
   * 超长的路径 / URL 由 .code-wrap 放行折行（窄屏兜底）。 */
  white-space: nowrap;
  overflow-wrap: normal;
}
/* 超长内联代码（路径 / URL）允许折行，避免窄屏把页面撑出横向滚动 */
.article code.code-wrap {
  white-space: normal;
  overflow-wrap: break-word;
}
.article pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  overflow-x: auto;
  font-size: .85rem;
  line-height: 1.6;
}
.article pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  word-break: normal;
  /* 终端输出保持原样：不折行，横向滚动 */
  white-space: pre;
  overflow-wrap: normal;
}
.article strong { font-weight: 680; }

.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.article th, .article td {
  border: 1px solid var(--border);
  padding: 8px 11px;
  text-align: left;
  /* 单元格文本在 Y 方向居中（上下居中），不再顶对齐 */
  vertical-align: middle;
}
.article th { background: var(--surface-2); font-weight: 650; white-space: nowrap; }
.article tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
/* 表格里的代码（路径、命令）不该被拆成两行：
 * 保持整段不换行，表格本身已有 overflow-x:auto 兜底。 */
.article td code { white-space: nowrap; }

.article .note {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: .94rem;
}

/* 译文标注：AI 译文的提示条，固定出现在正文最前方（视频/声明之上）。
 * 比正文小一号、灰字、左侧细竖线，确保不抢正文但不至于看不见。 */
.article .ai-note {
  font-size: 1.06rem;
  font-weight: 700;
  line-height: 1.7;
  color: var(--text);
  background: var(--surface-2);
  border-left: 3px solid var(--border-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 11px 16px;
  margin: 0 0 22px;
}

/* 声明体：文章最前方的黑体大字号声明（来源、作者等）。
 * 比正文字号明显更大 + 加粗，确保一眼就能看到，但不用彩色以免喧宾夺主。 */
.article .lead {
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1.65;
  letter-spacing: -.005em;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}

/* ---------- 文章配图 / 视频 / 附件 ---------- */

/* 配图：整幅自适应宽度，浅边框与圆角，和卡片的观感一致 */
.article figure { margin: 0; }
.article .shot img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.article figcaption {
  margin-top: .55em;
  font-size: .86rem;
  line-height: 1.65;
  color: var(--text-3);
}
.article figcaption a { color: var(--accent); }

/* 视频嵌入：16:9 自适应容器 —— 第三方播放器给的是固定高度，
 * 用 aspect-ratio 包一层，窄屏才不会溢出或留黑边 */
.article .embed-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.article .embed-frame iframe {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* 附件下载卡片 */
.article .dl {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 14px 16px;
}
.article .dl-main { flex: 1 1 260px; min-width: 0; }
.article .dl-name { font-weight: 650; }
.article .dl-meta { margin-top: 2px; font-size: .82rem; color: var(--text-3); }
.article .dl-desc { margin-top: 6px; font-size: .9rem; line-height: 1.7; color: var(--text-2); }
.article .dl-btn {
  flex: 0 0 auto;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--accent);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: .88rem;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}
.article .dl-btn:hover { border-color: var(--accent); text-decoration: none; }

/* 留言失败提示里的「重试」按钮 */
.link-btn {
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: .88rem;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.link-btn:hover { border-color: var(--accent); }

.kvlist { display: grid; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.kvlist > div {
  display: grid;
  grid-template-columns: 40% 1fr;
  border-bottom: 1px solid var(--border);
  font-size: .92rem;
}
.kvlist > div:last-child { border-bottom: 0; }
.kvlist dt, .kvlist .k {
  padding: 9px 13px;
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 600;
}
.kvlist dd, .kvlist .v { padding: 9px 13px; margin: 0; min-width: 0; }

/* ---------- 留言 ---------- */
.comments {
  margin-top: 46px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}
.comments h2 { font-size: 1.16rem; margin-bottom: 4px; }
.comments .sub { color: var(--text-3); font-size: .88rem; margin-bottom: 20px; }

.cform {
  display: grid;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.cform .row { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { font-size: .82rem; color: var(--text-2); font-weight: 600; }
.field input, .field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 16px; /* 防止 iOS 聚焦时自动放大 */
  line-height: 1.6;
  transition: border-color .15s;
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 108px; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: .92rem;
  font-weight: 650;
  cursor: pointer;
  min-height: 44px;
  justify-self: start;
  transition: filter .15s, opacity .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }

.form-msg { font-size: .86rem; margin: 0; }
.form-msg.err { color: var(--danger); }
.form-msg.ok { color: var(--accent); }

.clist {
  display: grid;
  gap: 12px;
  margin-top: 22px;
  /* 留言是**访客可控**的内容：可能贴进来一长串不可断的字符
   * （实测有人贴了 2000 个字母，或一条超长 URL）。
   * 默认的 auto 轨道按 max-content 撑开 → 整页被带到 13000px 宽，
   * 手机上直接横向拉一大片。minmax(0, 1fr) 明确允许轨道缩到容器宽度，
   * 再由下面 .citem-body 的 overflow-wrap 把长串断行。
   * （正文里刻意不用 overflow-wrap:anywhere —— 那会把 main 断成 mai/n，
   *   留言区是访客内容，可以断；正文不行。） */
  grid-template-columns: minmax(0, 1fr);
}
.citem {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  min-width: 0;
}
.citem-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 5px;
  flex-wrap: wrap;
  min-width: 0;
}
.citem-name { font-weight: 650; font-size: .92rem; overflow-wrap: break-word; }
.citem-time { color: var(--text-3); font-size: .78rem; font-variant-numeric: tabular-nums; }
.citem-body {
  color: var(--text-2);
  font-size: .93rem;
  line-height: 1.7;
  white-space: pre-wrap;
  /* 不可断的长串（2000 个字母 / 长 URL）必须能断行，否则会把整页撑宽 */
  overflow-wrap: break-word;
}

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: .82rem;
}
.site-footer .wrap {
  padding: 22px 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }

  .sidebar {
    position: sticky;
    top: calc(var(--header-h) + env(safe-area-inset-top));
    z-index: 40;
    margin: 0 -16px;
    padding: 8px 16px;
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .sidebar-title { display: none; }
  .catnav {
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .catnav::-webkit-scrollbar { display: none; }
  .catnav button {
    white-space: nowrap;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    padding: 7px 14px;
    min-height: 36px;
    scroll-snap-align: start;
  }
  .catnav button[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
  }
  .catnav button[aria-pressed="true"] .count {
    color: var(--accent-ink);
    opacity: .72;
  }
  .catnav .count { margin-left: 2px; }
}

@media (max-width: 720px) {
  body { font-size: 15.5px; }
  .wrap { padding: 20px 16px 44px; }

  .header-inner { padding: 9px 16px; gap: 10px; }
  .brand-sub { display: none; }
  .brand-title { font-size: 1rem; }
  .lang-switch button { padding: 5px 10px; font-size: .8rem; }

  .cards { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .card-body { padding: 14px 15px 15px; }
  .card-summary { -webkit-line-clamp: 5; }

  /* 排序下拉框：字号不小于 16px，避免 iOS 聚焦时自动放大页面 */
  .sort-control { width: 100%; margin-left: 0; }
  .sort-label { font-size: .84rem; }
  #sort-select { font-size: 16px; flex: 1; min-width: 0; }

  .post-title { font-size: 1.42rem; }
  .article { font-size: 1rem; line-height: 1.8; }
  .article .lead { font-size: 1.16rem; padding: 14px 15px; }
  .article h2 { font-size: 1.12rem; margin-top: 1.7em; }
  .article table { font-size: .84rem; }
  .article th, .article td { padding: 7px 9px; }
  /* 移动端表格里的代码：允许折行，但**不允许断在标识符中间**。
   *
   * 这里踩过两次坑，都是 `break-*` 的取值造成的：
   *  · `word-break: break-all` —— 它把每个单元格的 min-content 压到 1 个字符，
   *    自动布局于是把四列表格挤到每个格子只有十几个像素，
   *    结果 `main` 被断成「mai / n」、「trans」断成「tran / s」，
   *    实测 390px 下 10 个、320px 下 13 个断点全落在标识符中间。
   *  · `overflow-wrap: anywhere` —— 同样会缩小 min-content，实测几乎和 break-all 一样糟。
   *
   * `overflow-wrap: break-word` 恰恰不改变 min-content 宽度：表格先按「最长不可断词」
   * 算出各列该多宽，只有当某一段确实放不下时才在段内折行，
   * 因此能优先断在 `/`、`_`、`.`、`-` 这些天然断点。实测断点全部落在分隔符上。
   * 代价是含长路径的那张表格会略微超出容器、需要横向滑动，
   * 但表格本身有 overflow-x:auto，页面不会横向溢出 —— 这比把路径切成碎块更可读。 */
  .article td code { white-space: normal; word-break: normal; overflow-wrap: break-word; }

  .kvlist > div { grid-template-columns: minmax(0, 1fr); }
  .kvlist .k { padding-bottom: 2px; border-bottom: 0; }

  .cform { padding: 15px; }
  .field input, .field textarea { padding: 12px 13px; }
  .btn { width: 100%; }

  .site-footer .wrap { flex-direction: column; gap: 6px; }
}

/* 超窄屏 */
@media (max-width: 360px) {
  .lang-switch button { padding: 5px 8px; }
  .header-inner { padding: 8px 12px; }
  .wrap { padding-left: 13px; padding-right: 13px; }
}

/* 打印 */
@media print {
  .site-header, .sidebar, .comments, .site-footer { display: none !important; }
  body { background: #fff; color: #000; }
}
