/* ==========================================================================
   site.css — 全站唯一样式表（纯静态，无构建工具，无外部字体/CDN）
   路径：/assets/css/site.css
   响应式三档：默认（<768px 移动优先） / ≥768px / ≥1024px
   可访问性：正文对比度 ≥ 7:1，链接/按钮 ≥ 4.5:1，焦点可见，支持 prefers-reduced-motion
   横向溢出防护：320px 宽度下无横向滚动（见文件末尾"防溢出加固"一节）
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 设计令牌（Design Tokens）
   -------------------------------------------------------------------------- */
:root {
  /* 配色 —— 亮色主题 */
  --c-bg: #ffffff;
  --c-bg-subtle: #f6f8fa;
  --c-bg-raised: #ffffff;
  --c-bg-inverse: #1f2328;

  --c-text: #1f2328;            /* 对白色 ≈16.1:1 */
  --c-text-muted: #57606a;      /* 对白色 ≈7.0:1（AA，普通正文安全）*/
  --c-text-soft: #6e7781;       /* 对白色 ≈5.0:1（仅用于辅助标签）*/
  --c-text-inverse: #ffffff;

  --c-accent: #0b57d0;          /* 对白色 ≈6.4:1，可作正文链接 */
  --c-accent-strong: #0741a0;
  --c-accent-soft: #dbe9ff;
  --c-accent-contrast-on: #ffffff; /* 用在 --c-accent 背景上的文字色 */

  --c-success: #1a7f37;         /* ≈4.9:1 */
  --c-warn: #8a6100;            /* ≈4.9:1 */
  --c-danger: #b3261e;          /* ≈5.4:1 */

  --c-border: #d8dee4;
  --c-border-strong: #b1b9c0;
  --c-focus: #0b57d0;

  /* 间距（4px 基准） */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  /* 圆角 */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  /* 阴影 */
  --sh-sm: 0 1px 2px rgba(31, 35, 40, 0.08);
  --sh-md: 0 2px 8px rgba(31, 35, 40, 0.10);
  --sh-lg: 0 8px 24px rgba(31, 35, 40, 0.14);

  /* 排版 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;
  --fs-body: clamp(1rem, 0.95rem + 0.2vw, 1.0625rem);
  --lh-tight: 1.25;
  --lh-body: 1.65;
  --lh-prose: 1.75;

  /* 布局 */
  --container-max: 1120px;
  --container-narrow: 760px;
  --container-pad: var(--s-3);
  --header-h: 56px;

  /* 广告位最小高度（防 CLS） */
  --ad-min-horizontal: 102px;
  --ad-min-rectangle: 260px;
  --ad-min-fluid: 120px;

  /* 组件默认 */
  --grid-min-card: 240px;
}

/* --------------------------------------------------------------------------
   2. 重置与基础
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--s-3));
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--c-text);
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--s-3);
  line-height: var(--lh-tight);
  font-weight: 700;
  overflow-wrap: anywhere;
}

h1 { font-size: clamp(1.5rem, 1.25rem + 1.2vw, 2.125rem); }
h2 { font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem); }
h3 { font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.25rem); }
h4 { font-size: 1.0625rem; }

p {
  margin: 0 0 var(--s-4);
  overflow-wrap: anywhere;
}

a {
  color: var(--c-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--c-accent-strong);
  text-decoration-thickness: 2px;
}

ul, ol {
  margin: 0 0 var(--s-4);
  padding-inline-start: var(--s-5);
}

li { margin-block: var(--s-2); overflow-wrap: anywhere; }

img, video, canvas, svg, iframe, object, embed {
  max-width: 100%;
  height: auto;
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.9375em;
}

code {
  background: var(--c-bg-subtle);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 1px 5px;
  overflow-wrap: anywhere;
}

pre {
  display: block;
  background: var(--c-bg-inverse);
  color: var(--c-text-inverse);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin: 0 0 var(--s-4);
  overflow-x: auto;
  max-width: 100%;
  tab-size: 2;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  white-space: pre;
}

hr {
  border: 0;
  border-top: 1px solid var(--c-border);
  margin: var(--s-6) 0;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9375rem;
}

th, td {
  border: 1px solid var(--c-border);
  padding: var(--s-2) var(--s-3);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

thead th { background: var(--c-bg-subtle); font-weight: 700; }

blockquote {
  margin: 0 0 var(--s-4);
  padding: var(--s-2) var(--s-4);
  border-inline-start: 4px solid var(--c-accent);
  background: var(--c-bg-subtle);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--c-text);
}

[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   3. 可访问性辅助
   -------------------------------------------------------------------------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--c-focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--s-3);
  inset-block-start: -100px;
  z-index: 100;
  background: var(--c-accent);
  color: var(--c-accent-contrast-on);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md);
  text-decoration: none;
}

.skip-link:focus { inset-block-start: var(--s-3); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --------------------------------------------------------------------------
   4. 布局容器
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.container--narrow { max-width: var(--container-narrow); }

main { flex: 1 0 auto; }

.section {
  padding-block: var(--s-6);
}

.section > .container > :last-child { margin-bottom: 0; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  margin-bottom: var(--s-4);
  padding-bottom: var(--s-2);
  border-bottom: 2px solid var(--c-border);
}

.section-head h2 { margin: 0; }

.section-head__more {
  font-size: 0.9375rem;
  white-space: nowrap;
}

.section-note {
  color: var(--c-text-muted);
  font-size: 0.9375rem;
  margin: calc(-1 * var(--s-3)) 0 var(--s-4);
}

.stack > * + * { margin-top: var(--s-4); }

.divider { margin-block: var(--s-6); }

/* --------------------------------------------------------------------------
   5. 顶部导航（纯 CSS，移动端不换行溢出，短标签 + 换行）
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--header-h);
  flex-wrap: wrap;
  padding-block: var(--s-2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--c-text);
  text-decoration: none;
  margin-inline-end: auto;
}

.brand:hover { color: var(--c-accent); text-decoration: none; }

.brand__mark {
  display: block;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}

.brand__latin { color: var(--c-accent); }
.brand:hover .brand__latin { color: var(--c-accent-strong); }

.nav__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav__list li { margin: 0; }

.nav__link {
  display: inline-block;
  padding: 6px 10px;
  border-radius: var(--r-md);
  color: var(--c-text);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
}

.nav__link:hover {
  background: var(--c-bg-subtle);
  color: var(--c-accent-strong);
}

.nav__link[aria-current="page"] {
  color: var(--c-accent-strong);
  background: var(--c-accent-soft);
}

/* 移动端只保留核心入口，次要入口在页脚 */
.nav__item--optional { display: none; }

/* --------------------------------------------------------------------------
   6. 面包屑
   -------------------------------------------------------------------------- */
.breadcrumb {
  padding-block: var(--s-3);
  font-size: 0.875rem;
  color: var(--c-text-muted);
}

.breadcrumb__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumb__list li {
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--s-1);
  min-width: 0;
}

.breadcrumb__list li::before {
  content: "/";
  color: var(--c-text-soft);
}

.breadcrumb__list li:first-child::before { content: none; }

.breadcrumb a { color: var(--c-text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--c-accent-strong); text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--c-text); }

/* --------------------------------------------------------------------------
   7. 页首 / Hero
   -------------------------------------------------------------------------- */
.page-intro { padding-block: var(--s-5) var(--s-4); }

.page-intro__title { margin-bottom: var(--s-2); }

.page-intro__lede {
  font-size: 1.0625rem;
  color: var(--c-text-muted);
  max-width: 68ch;
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   8. 卡片网格（首页工具分类）
   -------------------------------------------------------------------------- */
.card-grid {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(var(--grid-min-card), 100%), 1fr)
  );
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4);
  background: var(--c-bg-raised);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  min-width: 0;
}

.card:hover {
  border-color: var(--c-border-strong);
  box-shadow: var(--sh-md);
  transform: translateY(-1px);
}

.card__title {
  margin: 0;
  font-size: 1.0625rem;
  line-height: var(--lh-tight);
}

.card__title a {
  color: var(--c-text);
  text-decoration: none;
}

/* 让整张卡片可点，同时保留真实链接（SEO + 键盘可达） */
.card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card { position: relative; }

.card__title a:focus-visible { outline-offset: 4px; }

.card__desc {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--c-text-muted);
  flex: 1 1 auto;
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  font-size: 0.8125rem;
  color: var(--c-text-soft);
}

.card--planned {
  background: var(--c-bg-subtle);
  border-style: dashed;
}

/* 虚线卡片底色是 subtle，text-soft 在其上只有 4.3:1，达不到 AA；
   元信息改用 muted（对 subtle ≈6.4:1）。 */
.card--planned .card__meta { color: var(--c-text-muted); }

/* --------------------------------------------------------------------------
   9. 徽章 / 标签
   -------------------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  background: var(--c-bg-subtle);
  color: var(--c-text-muted);
  border: 1px solid var(--c-border);
  white-space: nowrap;
}

.badge--new { background: var(--c-accent-soft); color: var(--c-accent-strong); border-color: var(--c-accent); }
/* 实测 #1a7f37 对 #e2f2e8 仅 4.38:1，不达标；改用更深绿字色，实测 ≈6.0:1 */
.badge--local { background: #e2f2e8; color: #14602a; border-color: #a6d7b8; }
/* 需要向第三方发运行时请求的页面用这一档，避免误标「本地处理」。
   #1b3a86 / #e8eefc 在浏览器里实测对比度 9.05:1（2026-11-05，getComputedStyle 取色后按 WCAG 公式算），
   满足 AA 正文要求。 */
.badge--net { background: #e8eefc; color: #1b3a86; border-color: #b6c6ea; }
.badge--planned { background: #fff5e5; color: #6b4a00; border-color: #f0cfa0; }

/* --------------------------------------------------------------------------
   10. 按钮与表单控件
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 10px 18px;
  min-height: 40px;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--c-accent);
  color: var(--c-accent-contrast-on);
  transition: background-color 0.15s ease, border-color 0.15s ease;
  max-width: 100%;
}

.btn:hover { background: var(--c-accent-strong); color: var(--c-accent-contrast-on); text-decoration: none; }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn--secondary {
  background: var(--c-bg-raised);
  color: var(--c-text);
  border-color: var(--c-border-strong);
}

.btn--secondary:hover { background: var(--c-bg-subtle); color: var(--c-accent-strong); }

.btn--ghost {
  background: transparent;
  color: var(--c-accent);
  border-color: transparent;
}

.btn--ghost:hover { background: var(--c-accent-soft); color: var(--c-accent-strong); }

.btn--danger { background: var(--c-danger); color: #fff; }

.btn--sm { padding: 6px 12px; min-height: 32px; font-size: 0.875rem; }
.btn--block { width: 100%; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  align-items: center;
}

.field { margin-bottom: var(--s-4); }

.field__label,
label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: var(--s-2);
  color: var(--c-text);
}

.field__hint {
  display: block;
  font-size: 0.8125rem;
  color: var(--c-text-muted);
  margin-top: var(--s-1);
}

.input,
.select,
.textarea,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="date"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 10px var(--s-3);
  min-height: 40px;
  font: inherit;
  color: var(--c-text);
  background: var(--c-bg-raised);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
}

.textarea,
textarea { min-height: 120px; resize: vertical; }

.input:focus,
.select:focus,
.textarea:focus,
textarea:focus,
select:focus,
input:focus {
  border-color: var(--c-accent);
  outline: 3px solid var(--c-accent-soft);
  outline-offset: 0;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--c-accent);
}

input[type="range"] { width: 100%; accent-color: var(--c-accent); }

.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  margin-block: var(--s-2);
}

.choice label,
.choice .field__label { margin: 0; font-weight: 500; }

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
}

.field-row > * { flex: 1 1 180px; min-width: 0; }

fieldset {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin: 0 0 var(--s-4);
}

legend { padding-inline: var(--s-2); font-weight: 600; }

/* --------------------------------------------------------------------------
   11. 工具页：交互区 / 结果区
   -------------------------------------------------------------------------- */
.tool-panel {
  background: var(--c-bg-raised);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  margin-bottom: var(--s-5);
  box-shadow: var(--sh-sm);
}

.tool-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin: calc(-1 * var(--s-4)) calc(-1 * var(--s-4)) var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: var(--c-bg-subtle);
  border-bottom: 1px solid var(--c-border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.tool-panel__head h2,
.tool-panel__head h3 {
  margin: 0;
  font-size: 1rem;
}

.tool-panel > :last-child { margin-bottom: 0; }

.tool-panel--result { background: var(--c-bg-subtle); }

/* 结果区状态提示：放在标题之外，避免把动态状态文字混进 h2 供读屏导航 */
.stale-tag {
  display: block;
  margin: calc(-1 * var(--s-2)) 0 var(--s-3);
  color: var(--c-warn);
  font-weight: 600;
  font-size: 0.8125rem;
}

.tool-placeholder {
  border: 2px dashed var(--c-border-strong);
  border-radius: var(--r-md);
  padding: var(--s-6) var(--s-4);
  text-align: center;
  color: var(--c-text-muted);
  background: var(--c-bg);
  font-size: 0.9375rem;
}

/* 拖放区（图片/音视频类工具通用外壳） */
.dropzone {
  display: grid;
  place-items: center;
  gap: var(--s-2);
  min-height: 140px;
  padding: var(--s-5);
  border: 2px dashed var(--c-border-strong);
  border-radius: var(--r-lg);
  background: var(--c-bg-subtle);
  text-align: center;
  color: var(--c-text-muted);
  cursor: pointer;
}

.dropzone:hover,
.dropzone.is-over {
  border-color: var(--c-accent);
  background: var(--c-accent-soft);
  color: var(--c-accent-strong);
}

/* 结果输出 */
.output {
  background: var(--c-bg-inverse);
  color: var(--c-text-inverse);
  border-radius: var(--r-md);
  padding: var(--s-4);
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  margin: 0;
}

.output:empty { display: none; }

.output--light {
  background: var(--c-bg);
  color: var(--c-text);
  border: 1px solid var(--c-border-strong);
}

.result-empty {
  padding: var(--s-5);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-bg);
  color: var(--c-text-muted);
  text-align: center;
  font-size: 0.9375rem;
}

/* 统计数字条 */
.stat-row {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr));
  margin-bottom: var(--s-4);
}

.stat {
  padding: var(--s-3);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-bg-raised);
}

.stat__value {
  display: block;
  font-size: 1.375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.stat__label {
  display: block;
  font-size: 0.8125rem;
  color: var(--c-text-muted);
}

/* 预览画布/图片容器 */
.preview-box {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-bg-subtle);
  padding: var(--s-3);
  text-align: center;
  overflow: auto;
  max-width: 100%;
}

.preview-box img,
.preview-box canvas,
.preview-box video {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-sm);
}

/* 棋盘底纹（透明图预览） */
.preview-box--alpha {
  background-image:
    linear-gradient(45deg, #e6e9ec 25%, transparent 25%),
    linear-gradient(-45deg, #e6e9ec 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e6e9ec 75%),
    linear-gradient(-45deg, transparent 75%, #e6e9ec 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* 进度 / 状态 */
.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  font-size: 0.875rem;
  color: var(--c-text-muted);
  min-height: 24px;
}

.progress {
  appearance: none;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--c-bg-subtle);
  overflow: hidden;
}

.progress::-webkit-progress-bar { background: var(--c-bg-subtle); }
.progress::-webkit-progress-value { background: var(--c-accent); }
.progress::-moz-progress-bar { background: var(--c-accent); }

/* --------------------------------------------------------------------------
   12. 提示块（含"本地处理"隐私声明）
   -------------------------------------------------------------------------- */
.notice {
  border: 1px solid var(--c-border);
  border-inline-start: 4px solid var(--c-border-strong);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4);
  background: var(--c-bg-subtle);
  font-size: 0.9375rem;
}

.notice > :last-child { margin-bottom: 0; }
.notice__title {
  display: block;
  font-weight: 700;
  margin-bottom: var(--s-1);
  color: var(--c-text);
}

.notice--privacy {
  background: #e2f2e8;
  border-color: #a6d7b8;
  border-inline-start-color: var(--c-success);
  color: #143d24;
  font-weight: 500;
}

.notice--info { border-inline-start-color: var(--c-accent); background: var(--c-accent-soft); border-color: #b5cdf5; color: #0a2f6e; }
.notice--warn { border-inline-start-color: var(--c-warn); background: #fff5e5; border-color: #f0cfa0; color: #5c4200; }
.notice--danger { border-inline-start-color: var(--c-danger); background: #fde7e6; border-color: #f2b8b4; color: #7a1a14; }

/* --------------------------------------------------------------------------
   13. 广告位占位（防 CLS：按格式预留最小高度）
   -------------------------------------------------------------------------- */
.ad-slot {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-block: var(--s-5);
  padding-inline: 0;
  min-height: var(--ad-min-horizontal);
  text-align: center;
  overflow: hidden;
}

.ad-slot[data-ad-slot="tool-top"] { margin-block-start: var(--s-4); }

.ad-slot[data-ad-format="rectangle"],
.ad-slot[data-ad-format="square"] { min-height: var(--ad-min-rectangle); }

.ad-slot[data-ad-format="fluid"] { min-height: var(--ad-min-fluid); }

.ad-slot[data-ad-format="auto"],
.ad-slot[data-ad-format="responsive"] { min-height: var(--ad-min-fluid); }

/* 占位态：虚线框 + 固定高度，开发时一眼看到位置；由 ad-loader.js 设置状态 */
.ad-slot[data-ad-state="placeholder"],
.ad-slot[data-ad-state="not-configured"] {
  display: grid;
  place-items: center;
  min-height: var(--ad-min-horizontal);
  padding: var(--s-3);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--r-md);
  background: repeating-linear-gradient(
    45deg,
    var(--c-bg-subtle),
    var(--c-bg-subtle) 10px,
    #ffffff 10px,
    #ffffff 20px
  );
  color: var(--c-text-soft);
  font-size: 0.8125rem;
  text-align: center;
}

.ad-slot[data-ad-state="placeholder"][data-ad-format="rectangle"],
.ad-slot[data-ad-state="placeholder"][data-ad-format="square"] { min-height: var(--ad-min-rectangle); }
.ad-slot[data-ad-state="placeholder"][data-ad-format="fluid"],
.ad-slot[data-ad-state="placeholder"][data-ad-format="auto"] { min-height: var(--ad-min-fluid); }

/* 占位说明文字由 CSS 生成，不写进 DOM，注入真实广告时自动消失 */
.ad-slot[data-ad-state="placeholder"]::before {
  content: "广告位 " attr(data-ad-slot) "（当前未投放）";
}

.ad-slot[data-ad-state="placeholder"][data-ad-reason]::after {
  content: " · " attr(data-ad-reason);
}

/* 关闭态：折叠，不占版面（enabled=false 或 ?ads=off 调试） */
.ad-slot[data-ad-state="disabled"] {
  min-height: 0;
  margin-block: 0;
  border: 0;
  padding: 0;
  background: none;
}

/* 已注入：高度交给广告本身，不锁死 min-height 以免留白 */
.ad-slot[data-ad-state="rendered"] {
  min-height: 0;
  overflow: visible;
}

.ad-slot ins,
.ad-slot iframe {
  display: block;
  margin-inline: auto;
  max-width: 100%;
}

/* 侧栏广告（≥1024px 才出现在侧栏） */
.ad-slot--side { min-height: var(--ad-min-rectangle); }

/* --------------------------------------------------------------------------
   14. How-to 步骤
   -------------------------------------------------------------------------- */
.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 0;
}

.steps li {
  position: relative;
  counter-increment: step;
  padding: 0 0 var(--s-4) var(--s-7);
  margin: 0;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: -2px;
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  background: var(--c-accent);
  color: var(--c-accent-contrast-on);
  font-size: 0.875rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.steps li::after {
  content: "";
  position: absolute;
  inset-inline-start: 13px;
  inset-block-start: 32px;
  width: 2px;
  height: calc(100% - 34px);
  background: var(--c-border);
}

.steps li:last-child::after { content: none; }
.steps li > :last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   15. FAQ（details / summary）
   -------------------------------------------------------------------------- */
.faq { margin: 0; }

.faq__item {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  margin-bottom: var(--s-3);
  background: var(--c-bg-raised);
  overflow-wrap: anywhere;
}

.faq__item > summary {
  cursor: pointer;
  padding: var(--s-3) var(--s-5) var(--s-3) var(--s-4);
  font-weight: 600;
  list-style: none;
  position: relative;
  border-radius: var(--r-md);
}

.faq__item > summary::-webkit-details-marker { display: none; }
.faq__item > summary::marker { content: ""; }

.faq__item > summary::after {
  content: "+";
  position: absolute;
  inset-inline-end: var(--s-4);
  inset-block-start: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--c-accent);
  line-height: 1;
}

.faq__item[open] > summary::after { content: "−"; }
.faq__item[open] > summary { border-bottom: 1px solid var(--c-border); border-radius: var(--r-md) var(--r-md) 0 0; }
.faq__item > summary:hover { background: var(--c-bg-subtle); }

.faq__answer {
  padding: var(--s-4);
  color: var(--c-text);
  font-size: 0.9375rem;
}

.faq__answer > :last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   16. 相关工具内链
   -------------------------------------------------------------------------- */
.related {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  list-style: none;
  padding: 0;
  margin: 0;
}

.related li { margin: 0; }

.related__link {
  display: block;
  height: 100%;
  padding: var(--s-4);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-bg-raised);
  text-decoration: none;
  color: var(--c-text);
}

.related__link:hover {
  border-color: var(--c-accent);
  background: var(--c-accent-soft);
  color: var(--c-accent-strong);
  text-decoration: none;
}

.related__name {
  display: block;
  font-weight: 700;
  margin-bottom: var(--s-1);
}

.related__desc {
  display: block;
  font-size: 0.875rem;
  color: var(--c-text-muted);
}

.related__link:hover .related__desc { color: var(--c-accent-strong); }

/* --------------------------------------------------------------------------
   17. 文章排版（博客 / 说明文档）
   -------------------------------------------------------------------------- */
.prose {
  max-width: 72ch;
  font-size: var(--fs-body);
  line-height: var(--lh-prose);
}

.prose > :first-child { margin-top: 0; }
.prose h2 { margin-top: var(--s-7); padding-bottom: var(--s-2); border-bottom: 1px solid var(--c-border); }
.prose h3 { margin-top: var(--s-6); }
.prose h4 { margin-top: var(--s-5); }
.prose ul, .prose ol { padding-inline-start: var(--s-6); }
.prose li { margin-block: var(--s-1); }
.prose img { border-radius: var(--r-md); border: 1px solid var(--c-border); }
.prose h2, .prose h3 { scroll-margin-top: calc(var(--header-h) + var(--s-4)); }

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  font-size: 0.875rem;
  color: var(--c-text-muted);
  margin-bottom: var(--s-5);
}

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

.article-list li {
  padding-block: var(--s-4);
  border-bottom: 1px solid var(--c-border);
  margin: 0;
}

.article-list time {
  display: block;
  font-size: 0.8125rem;
  color: var(--c-text-soft);
  margin-top: var(--s-1);
}

/* 目录 */
.toc {
  background: var(--c-bg-subtle);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin-bottom: var(--s-5);
  font-size: 0.9375rem;
}

.toc__title { margin: 0 0 var(--s-2); font-size: 0.9375rem; }
.toc ol { margin: 0; padding-inline-start: var(--s-5); }

/* --------------------------------------------------------------------------
   18. 页脚
   -------------------------------------------------------------------------- */
.site-footer {
  flex-shrink: 0;
  margin-top: var(--s-8);
  padding-block: var(--s-6);
  background: var(--c-bg-subtle);
  border-top: 1px solid var(--c-border);
  font-size: 0.9375rem;
  color: var(--c-text-muted);
}

.site-footer__grid {
  display: grid;
  gap: var(--s-5);
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  margin-bottom: var(--s-5);
}

.site-footer__title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text);
  margin: 0 0 var(--s-2);
}

.site-footer__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-footer__list li { margin: 0 0 var(--s-2); }

.site-footer a { color: var(--c-accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; color: var(--c-accent-strong); }

.site-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  align-items: center;
  justify-content: space-between;
  padding-top: var(--s-4);
  border-top: 1px solid var(--c-border);
  font-size: 0.8125rem;
}

.site-footer__bottom p { margin: 0; }

/* --------------------------------------------------------------------------
   19. 杂项
   -------------------------------------------------------------------------- */
.kv {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  gap: var(--s-2) var(--s-4);
  font-size: 0.9375rem;
  margin: 0;
}

.kv dt { color: var(--c-text-muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--s-4);
}

.copy-hint { font-size: 0.8125rem; color: var(--c-text-muted); }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  list-style: none;
  padding: 0;
  margin: 0 0 var(--s-4);
}

.tag-list li { margin: 0; }

.tag {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-pill);
  background: var(--c-bg-raised);
  color: var(--c-text);
  font-size: 0.875rem;
  text-decoration: none;
}

.tag:hover { border-color: var(--c-accent); color: var(--c-accent-strong); background: var(--c-accent-soft); }

/* --------------------------------------------------------------------------
   20. 防溢出加固（320px 无横向滚动的兜底）
   -------------------------------------------------------------------------- */
html { overflow-x: hidden; }

body, .container, main, section, .tool-panel, .card, .notice, .faq__item {
  min-width: 0;
}

.flex-guard { min-width: 0; }

.nowrap-col { white-space: nowrap; }

@media (max-width: 479.98px) {
  :root { --container-pad: var(--s-3); }
  .tool-panel { padding: var(--s-3); }
  .tool-panel__head {
    margin-inline: calc(-1 * var(--s-3));
    padding-inline: var(--s-3);
  }
  .card { padding: var(--s-3); }
}

/* --------------------------------------------------------------------------
   21. 平板档：≥768px
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  :root {
    --header-h: 64px;
    --container-pad: var(--s-5);
  }

  .section { padding-block: var(--s-7); }
  .nav__item--optional { display: block; }
  .site-header__inner { flex-wrap: nowrap; }
  .brand { font-size: 1.125rem; }
  .tool-panel { padding: var(--s-5); }
  .page-intro { padding-block: var(--s-6) var(--s-5); }
  .ad-slot { margin-block: var(--s-6); }
  .faq__answer { padding: var(--s-4) var(--s-5); }
}

/* --------------------------------------------------------------------------
   22. 桌面档：≥1024px
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) {
  :root { --grid-min-card: 260px; }

  .layout-with-side {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: var(--s-6);
    align-items: start;
  }

  .layout-with-side > .sidebar {
    position: sticky;
    top: calc(var(--header-h) + var(--s-4));
  }

  .nav__link { padding: 8px 12px; }
  .card-grid { gap: var(--s-5); }
  .steps li { padding-left: var(--s-8); }
  .steps li::before { inset-inline-start: var(--s-2); }
  .steps li::after { inset-inline-start: 17px; }
}
