/* ============================================================
   设计令牌
   布局节奏参考了同品类的通用做法（工具卡靠上、横向缩略图条、独立对比卡），
   但这里的每一个色值、间距、组件都是我们自己写的。
   ============================================================ */
:root {
  --content-width: 1080px;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --border: #e4e7ec;
  --border-strong: #cfd4dc;

  --text: #232a35;
  --text-muted: #5c6675;
  --text-faint: #8b95a5;

  --primary: #2f6fd0;
  --primary-hover: #275fb4;
  --danger: #d9574c;
  --danger-hover: #c2473d;
  --success: #2f8f4e;
  --success-hover: #27793f;
  --dark: #39404e;
  --dark-hover: #2e343f;
  --accent: #d9772b;

  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  /* 夜间模式要覆盖的语义色（原先散落在各处的硬编码值，收进变量才能统一切换） */
  --primary-soft: #f4f8ff;
  --success-soft: #e2f4e7;
  --success-text: #1e7a3c;
  --success-border: #bfe5cb;
  --checker-a: #f6f7f9;
  --checker-b: #e4e7ec;
  --ghost: #fcfcfd;
  --pad: 20px;
  --row-gap: 14px;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
        "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

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

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

/* 键盘焦点必须看得见 —— 竞品这一点是空白，我们不做同样的事 */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

/* ============================================================
   顶栏
   ============================================================ */
.topbar {
  display: flex; align-items: center; gap: 16px;
  max-width: var(--content-width);
  margin: 0 auto; padding: 14px 20px;
}
/* 窄屏：顶栏元素太多（品牌 + 三个导航 + 语言 + 主题开关），不换行会把主题开关挤出屏幕。
   品牌名也不允许折行，否则 "CompressDog" 会断成两行、把顶栏撑高。 */
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 12px 16px; }
  /* 两行排布：第一行 品牌 + 主题开关（开关靠右），第二行 导航 + 语言。
     之前把语言和开关都靠右，两者挤在一起，开关被顶出屏幕。 */
  .brand { order: 1; }
  .brand__name { white-space: nowrap; }
  #themeToggle { order: 2; margin-left: auto; }
  .topnav { order: 3; gap: 14px; }
  .langs { order: 4; margin-left: auto; }
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand__mark {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 700;
}
.brand__name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.topnav { display: flex; gap: 18px; margin-left: auto; font-size: 14px; }
.topnav a { color: var(--text-muted); }
.topnav a:hover { color: var(--text); }
.topnav a.is-active { color: var(--primary); font-weight: 600; }
.langs { display: flex; gap: 8px; font-size: 13px; }
.langs a { color: var(--text-muted); }
.langs a[aria-current="true"] { color: var(--text); font-weight: 600; }

/* ============================================================
   首屏
   ============================================================ */
.page { max-width: var(--content-width); margin: 0 auto; padding: 0 20px 60px; }

.hero__title {
  margin: 18px 0 14px;
  font-size: 32px; line-height: 1.25; font-weight: 700; text-align: center;
  letter-spacing: -.02em;
}
.hero__text { margin: 0 auto 12px; max-width: 820px; color: var(--text-muted); }
.hero__points {
  margin: 0 auto 22px; max-width: 820px; padding-left: 22px;
  color: var(--text-muted);
}
.hero__points li { margin: 4px 0; }

/* ============================================================
   标签栏 + 工具卡
   ============================================================ */
.tool { margin-top: 6px; }

.toolcard {
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  box-shadow: var(--shadow);
  padding: var(--pad);
}

.notice { margin: 0 0 12px; color: var(--danger); }

.toolbar { display: flex; justify-content: center; gap: 10px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  position: relative;
  padding: 9px 18px; border: 0; border-radius: var(--radius-sm);
  font: inherit; font-size: 13px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: var(--dark); cursor: pointer;
  transition: background-color .12s ease;
}
.btn:hover:not(:disabled) { background: var(--dark-hover); }
.btn:disabled { cursor: not-allowed; opacity: .45; }
.btn--primary { background: var(--primary); }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn--danger { background: var(--danger); }
.btn--danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn--success { background: var(--success); }
.btn--success:hover:not(:disabled) { background: var(--success-hover); }
.btn--small { padding: 5px 11px; font-size: 11px; }
.ico { font-size: 13px; line-height: 1; }

.badge {
  display: inline-grid; place-items: center; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 9px;
  background: rgba(0, 0, 0, .28); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: 0;
}
.badge[hidden] { display: none; }

/* ---------- 拖放区 ---------- */
.drop {
  margin: 16px 0;
  min-height: 150px;
  display: grid; place-content: center; gap: 6px; text-align: center;
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--ghost);
}
/* 显式 display 会盖掉 [hidden] 的 display:none —— 必须补这一条，否则放了图拖放区也不消失 */
.drop[hidden] { display: none; }
/* 拖放区可点击 → 要看起来可点、也要有键盘焦点环 */
.drop[role="button"] { cursor: pointer; }
.drop[role="button"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.drop.is-over { border-color: var(--primary); background: var(--primary-soft); }
.drop__text { margin: 0; color: var(--text-faint); font-size: 17px; }
.drop__note { margin: 0; color: var(--text-faint); font-size: 12px; }

/* ---------- 横向缩略图条 ---------- */
.strip { display: flex; align-items: center; gap: 6px; margin: 14px 0; }
.strip[hidden] { display: none; }
.strip__list {
  display: flex; gap: 10px; overflow-x: auto; scroll-behavior: smooth;
  list-style: none; margin: 0; padding: 6px 8px; flex: 1;
  scrollbar-width: thin;
}
.strip__nav {
  flex: none; appearance: none; border: 0; background: none; cursor: pointer;
  color: #e79a8f; font-size: 30px; line-height: 1; padding: 6px 2px;
}
.strip__nav:hover { color: var(--danger); }
.strip__nav:disabled { opacity: .3; cursor: default; }

.thumb { flex: none; width: 132px; cursor: pointer; }
.thumb__frame {
  position: relative; width: 132px; height: 132px;
  border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2); border: 2px solid transparent;
}
.thumb__img { width: 100%; height: 100%; object-fit: cover; }
.thumb.is-selected .thumb__frame { border-color: var(--primary); }
.thumb__x {
  position: absolute; top: 3px; right: 3px; z-index: 3;
  width: 20px; height: 20px; display: grid; place-items: center;
  border: 0; border-radius: 3px; cursor: pointer;
  background: #fff; color: var(--text); font-size: 12px; line-height: 1;
}
/* 中央的格式角标（JPG / PNG…）；出结果后被 -N% 取代 */
.thumb__badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 2; color: #fff; font-size: 20px; font-weight: 700; letter-spacing: .06em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .7);
}
.thumb.has-result .thumb__badge { display: none; }
.thumb__name {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  padding: 3px 5px; background: linear-gradient(rgba(0, 0, 0, .55), rgba(0, 0, 0, 0));
  color: #fff;
  font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb__saving {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 3; display: none;
  color: #fff; font-size: 22px; font-weight: 700;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .65);
}
.thumb.has-result .thumb__name { display: none; }
.thumb.has-result .thumb__saving { display: block; }
.thumb__state {
  display: block; margin-top: 4px; text-align: center;
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb__state.is-warn { color: var(--danger); }
/* 带 GPS 的图在缩略图上就标红 —— 对比卡在压缩前不显示，这是用户唯一能提前看到的地方 */
.thumb__state.is-gps { color: var(--danger); font-weight: 600; }

/* ---------- 动作行 ---------- */
.actions { display: flex; justify-content: center; gap: 10px; }
/* 压缩/保存按钮现在位于设置区最下方，和上面的色度行拉开距离 */
.settings .actions { margin-top: 18px; }
/* 下载被浏览器拦下时给一句可见提示，否则用户分不清"坏了"和"被拦了" */
.actions__note {
  margin: 10px 0 0; text-align: center;
  color: var(--text-muted); font-size: 12px; line-height: 1.5;
}
.actions__note[hidden] { display: none; }

/* ---------- 设置区 ---------- */
.settings {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border);
  display: grid; gap: 11px;
}
.settings__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.settings__row[hidden] { display: none; }
.settings__label { color: var(--text-muted); min-width: 68px; }
.settings__row input[type="range"] { flex: 1; min-width: 140px; accent-color: var(--primary); }
.settings__row output { min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.settings__row input[type="number"] {
  width: 76px; padding: 4px 7px; font: inherit; font-size: 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.settings__row--modes { gap: 14px; }
.radio { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
/* 模式说明（例如「仅移除元数据」什么时候用、为什么没有质量设置） */
/* 输出格式选择器：分段控件，选中项深色（和参照站的观感一致） */
/* 转换中：与参照站一致的 PROCESSING 遮罩 + 条纹进度条（纯 CSS，无额外 JS 计时器） */
.thumb__busy, .thumb__bar { display: none; }
.thumb.is-busy .thumb__busy {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  position: absolute; inset: 0; z-index: 3;
  background: rgba(20, 23, 28, .55); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.thumb__spin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: thumbspin .8s linear infinite;
}
@keyframes thumbspin { to { transform: rotate(360deg); } }
/* 条纹进度条：不确定进度，用背景位移动画表达"在动" */
.thumb.is-busy .thumb__bar {
  display: block; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; z-index: 4;
  background: repeating-linear-gradient(45deg,
    rgba(255,255,255,.85) 0 6px, rgba(140,150,165,.85) 6px 12px);
  background-size: 200% 100%;
  animation: thumbbar 1s linear infinite;
}
@keyframes thumbbar { to { background-position: -34px 0; } }
@media (prefers-reduced-motion: reduce) {
  .thumb__spin, .thumb.is-busy .thumb__bar { animation: none; }
}
/* 完成后显示输出格式（对齐参照站缩略图上的 PNG 角标） */
.thumb__out { display: none; }
.thumb.has-result .thumb__out:not(:empty) {
  display: block; position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 4px 0; text-align: center;
  background: rgba(20, 23, 28, .78); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
}

.settings__row--formats { gap: 0; }
.settings__row--formats .fmt {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 14px; cursor: pointer; font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border); border-left-width: 0;
}
.settings__row--formats .fmt:first-of-type { border-left-width: 1px; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.settings__row--formats .fmt:last-of-type { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.settings__row--formats .fmt input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.settings__row--formats .fmt:has(input:checked) { background: var(--dark); border-color: var(--dark); color: #fff; }
.settings__row--formats .fmt:hover { color: var(--text); }
.settings__row--formats .fmt:has(input:checked):hover { color: #fff; }
.settings__row--formats[hidden] { display: none; }

.settings__hint {
  margin: 0; padding: 9px 12px;
  background: var(--surface-2); border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted); font-size: 13px; line-height: 1.55;
}
.settings__hint[hidden] { display: none; }

/* ---------- 压缩算法选择 ---------- */
/* 标签独占一行，卡片区占满整宽 —— 否则 5 张卡会在 1280px 下折成 4+1，很难看 */
.settings__row--algos { display: block; }
.settings__row--algos .settings__label { display: block; margin-bottom: 8px; min-width: 0; }
.algos {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
}
.algo {
  position: relative; display: block; cursor: pointer;
  padding: 9px 11px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  transition: border-color .12s ease, background-color .12s ease;
}
.algo:hover { border-color: var(--border-strong); }
/* 显式 display 会盖掉 [hidden]，必须自己声明 */
.algo[hidden] { display: none; }
.settings__row--algos[hidden] { display: none; }
/* :has() 在 Safari 15.4+ / Chrome 105+ / Firefox 121+ 可用，我们的基线是 Safari 16.4 */
.algo:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.algo:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 1px; }
/* 单选框视觉隐藏但保留在可访问性树与 Tab 序列里 */
.algo input {
  position: absolute; width: 1px; height: 1px; opacity: 0; margin: 0; pointer-events: none;
}
.algo__name {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.algo small { display: block; margin-top: 3px; color: var(--text-faint); font-size: 11px; line-height: 1.45; }
.algo__tag {
  display: inline-block; padding: 1px 7px; border-radius: 9px;
  background: var(--success-soft); color: var(--success-text); border: 1px solid var(--success-border);
  font-size: 10px; font-style: normal; font-weight: 700; letter-spacing: .02em;
}
.settings__row--check { align-items: flex-start; gap: 8px; }
.settings__row--check small { display: block; color: var(--text-faint); font-size: 12px; }
.unit { color: var(--text-muted); font-size: 13px; }

/* ============================================================
   对比卡
   ============================================================ */
.compare {
  margin-top: 22px; padding: var(--pad);
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}
.compare[hidden] { display: none; }
.compare__name {
  margin: 0 0 10px; text-align: center; font-weight: 700; font-size: 15px;
  word-break: break-all;
}
.compare__sizes {
  display: flex; justify-content: space-between; gap: 12px;
  margin-bottom: 10px; font-size: 14px; color: var(--text-muted);
}
.compare__sizes .is-good { color: var(--success); font-weight: 600; }
.compare__sizes .is-bad { color: var(--danger); font-weight: 600; }
/* 舞台高度由原图决定（不强制 4:3，否则方图两侧会留大片空白）；
   两层图都用 contain 居中，所以叠加时能精确对齐。
   背景用灰白棋盘格 —— 透明图能一眼看出透明区，也便于判断缩放是否超出边界。 */
.compare__stage {
  position: relative; width: 100%; max-width: 760px; margin: 0 auto;
  display: grid; place-items: center;
  border-radius: var(--radius-sm); overflow: hidden;
  background-color: var(--checker-a);
  background-image:
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%, transparent 75%, var(--checker-b) 75%),
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%, transparent 75%, var(--checker-b) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  cursor: default;
  touch-action: none;
}
/* 关掉原生图片拖拽。默认行为是拖动时生成一个半透明缩略图跟随鼠标，
   会抢走放大后的平移手势（表现为"拖不动图，只有个小图跟着鼠标"）。
   draggable="false" 是标准做法，-webkit-user-drag 是 WebKit/Blink 的额外保险。 */
.compare__stage img { -webkit-user-drag: none; user-select: none; }
.compare__stage.is-zoomed { cursor: grab; }
.compare__stage.is-panning { cursor: grabbing; }
/* 缩放只作用于两张图，**不动裁切层** —— 否则 clip 会跟着缩放，分割线就和标签错位了 */
.compare__img, .compare__after img { will-change: transform; }
.compare__img { max-width: 100%; max-height: 500px; width: auto; height: auto; }
/* 压缩结果盖在原图上，用 clip-path 切开 */
.compare__after {
  position: absolute; inset: 0; overflow: hidden;
}
.compare__after img { width: 100%; height: 100%; object-fit: contain; }
.compare__split {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 3px;
  background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); cursor: ew-resize;
}
.compare__split[hidden] { display: none; }
.compare__handle {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  font-size: 13px; letter-spacing: 1px;
}
.compare__hint { margin: 10px 0 0; text-align: center; color: var(--text-faint); font-size: 12px; }
.compare__meta { margin-top: 6px; text-align: center; color: var(--text-muted); font-size: 12px; word-break: break-word; }
.compare__meta.is-warn { color: var(--danger); }
.compare__actions { display: flex; justify-content: center; margin-top: 12px; }
/* 预览部分单独隐藏：删除元数据页在选中文件时只显示元数据框 */
.compare__preview[hidden] { display: none; }
/* 图像对比区单独一层：删除元数据页整块藏掉（那页没有可比的东西） */
.compare__visual[hidden] { display: none; }

/* 按格式分标签：两套面板各自独立。
   隐藏而不是销毁 —— JPEG 的设置在你切到 PNG 再切回来时原样还在。
   （共用一组控件再按格式改语义，就会出现"这个滑块在当前格式下算什么"的问题。） */
.settings__hint--warn { color: var(--danger); }
#pngColors { flex: 1; max-width: 320px; }
#pngColorsOut { min-width: 3ch; font-variant-numeric: tabular-nums; }

.settings[data-fmt="png"] .only-jpeg { display: none; }
.settings[data-fmt="jpeg"] .only-png { display: none; }

/* 标签栏 */
.fmttabs { display: flex; gap: 6px; margin: 0 0 12px; }
.fmttabs__tab {
  padding: 7px 16px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text-muted); font: inherit; font-weight: 700;
  cursor: pointer;
}
.fmttabs__tab:hover { border-color: var(--primary); color: var(--primary); }
.fmttabs__tab[aria-selected="true"] {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.fmttabs__tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.compare__actions .btn[hidden] { display: none; }

/* ---------- 缩放条 ---------- */
.compare__zoom {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 8px; color: var(--text-faint); font-size: 12px;
}
.compare__zoom-level { font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
.compare__zoom-level[hidden] { display: none; }
.compare__zoom-reset[hidden] { display: none; }

/* ---------- 元数据面板：压缩前列出内容，压缩后标出被清掉的项 ---------- */
.exif {
  margin-top: 16px; padding: 12px 14px;
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.exif[hidden] { display: none; }
.exif__head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.exif__title { font-weight: 700; font-size: 13px; }
.exif__summary { color: var(--text-muted); font-size: 12px; }
.exif__summary.is-good { color: var(--success); font-weight: 600; }
.exif__list {
  display: grid; gap: 3px 16px; margin: 0; padding: 0;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  list-style: none; font-size: 12px;
}
.exif__list li {
  display: flex; gap: 6px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.exif__list li b { color: var(--text); font-weight: 600; flex: none; }
.exif__list li.is-gone { color: var(--danger); text-decoration: line-through; opacity: .8; }
.exif__list li.is-gone b { color: var(--danger); }
/* 没有元数据时在框里说明"体积是怎么小下来的"，而不是留一个空框 */
.exif__note {
  margin: 0; color: var(--text-muted); font-size: 12px; line-height: 1.6;
}
.exif__note[hidden] { display: none; }
.exif__note em { font-style: normal; color: var(--text); font-weight: 600; }

/* ============================================================
   内容区
   ============================================================ */
.section { margin-top: 34px; }
.section h2 { margin: 0 0 10px; font-size: 24px; letter-spacing: -.01em; }
.section h3 { margin: 20px 0 8px; font-size: 18px; }
.section p { margin: 0 0 10px; color: var(--text-muted); }
.section ul { color: var(--text-muted); }
.section code {
  padding: 1px 5px; border-radius: 3px; background: var(--surface-2);
  font-size: .92em;
}
.guide-cta {
  display: block; margin-top: 14px; padding: 18px 20px;
  background: var(--dark); border-radius: var(--radius); color: #fff;
}
.guide-cta:hover { text-decoration: none; background: var(--dark-hover); }
.guide-cta strong { display: block; font-size: 18px; margin-bottom: 6px; }
.guide-cta span { display: block; color: #c9cfda; font-size: 14px; }
.guide-cta em { display: inline-block; margin-top: 10px; font-style: normal; font-weight: 700; font-size: 13px; }

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card {
  display: block; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: inherit;
}
.card:hover { text-decoration: none; border-color: var(--border-strong); }
.card strong { display: block; margin-bottom: 6px; color: var(--primary); }
.card span { display: block; color: var(--text-muted); font-size: 14px; }

/* ============================================================
   文章页 / 关于页 / 隐私页 / 指南索引
   ============================================================ */
.post, .related, .cta, .guides, .page > .section:first-of-type { max-width: 780px; margin-left: auto; margin-right: auto; }
.post .hero__title { text-align: left; font-size: 30px; margin-top: 22px; }
.post .hero__text { margin-left: 0; color: var(--text-muted); }
.post h2 { margin: 28px 0 8px; font-size: 21px; }
.post h3 { margin: 22px 0 6px; font-size: 17px; }
.post p, .post li { color: var(--text-muted); }
.post ul, .post ol { color: var(--text-muted); }
.post blockquote {
  margin: 14px 0; padding: 2px 0 2px 14px;
  border-left: 3px solid var(--border-strong); color: var(--text-muted);
}
.post pre {
  overflow-x: auto; padding: 12px 14px; background: var(--surface-2);
  border-radius: var(--radius-sm); font-size: 13px;
}
.post code { padding: 1px 5px; border-radius: 3px; background: var(--surface-2); font-size: .92em; }
.post pre code { padding: 0; background: none; }
.post table { width: 100%; margin: 14px 0; border-collapse: collapse; font-size: 14px; }
.post th, .post td { padding: 7px 10px; border: 1px solid var(--border); text-align: left; }
.post th { background: var(--surface-2); }
.post__meta { color: var(--text-faint); font-size: 13px; }
.related h2, .guides h2 { font-size: 20px; }
.related ul, .guides ul { padding-left: 20px; color: var(--text-muted); }
.cta { margin-top: 26px; }
.guides li { margin: 6px 0; }
.guides li span { display: block; color: var(--text-muted); font-size: 14px; }

/* ============================================================
   广告位（未配置时完全不渲染）
   ============================================================ */
.ad { min-height: 100px; margin: 22px 0; }

/* ============================================================
   页脚
   ============================================================ */
.footer {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  max-width: var(--content-width); margin: 0 auto;
  padding: 18px 20px 34px;
  border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: 13px;
}
.footer__links { display: flex; gap: 14px; }
.langs--footer { margin-left: auto; }
/* ---- 语言下拉 ----
   用 <details>/<summary> 原生开合，不需要 JS：文章页/关于页由 pageShell 渲染，
   不加载 app.js，JS 下拉在那些页面会失效。
   国旗是内联 SVG —— Windows 不渲染国旗 emoji（🇩🇪 会变成 "DE"）。 */
.langmenu { position: relative; }
.langmenu__btn {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border: 1px solid var(--border-strong); border-radius: 7px;
  font-size: 13px; color: var(--text-muted); user-select: none;
}
.langmenu__btn::-webkit-details-marker { display: none; }
.langmenu__btn::after { content: '▾'; font-size: 10px; opacity: .6; }
.langmenu[open] > .langmenu__btn { border-color: var(--primary); color: var(--primary); }
.langmenu__btn:hover { border-color: var(--primary); color: var(--primary); }
.langmenu__list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  margin: 0; padding: 6px; list-style: none; min-width: 165px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .16);
}
.langmenu__list a {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 6px;
  color: var(--text-muted); font-size: 13px; white-space: nowrap;
}
.langmenu__list a:hover { background: var(--bg); color: var(--text); }
.langmenu__list a[aria-current="true"] { color: var(--primary); font-weight: 600; }
.langmenu__flag {
  display: inline-flex; width: 19px; height: 13px; flex: none;
  border-radius: 2px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0, 0, 0, .14);
}
.langmenu__flag svg { width: 100%; height: 100%; display: block; }
/* 页脚那份同一套 markup，菜单要往上弹 */
.langs--footer .langmenu__list { top: auto; bottom: calc(100% + 6px); }


/* ============================================================
   窄屏：保持同一操作顺序，只是缩小与堆叠
   ============================================================ */
@media (max-width: 760px) {
  .hero__title { font-size: 25px; }
  :root { --pad: 16px; }
  .topnav { gap: 12px; font-size: 13px; }
  .brand__name { font-size: 15px; }
  .tab { padding: 8px 14px; font-size: 13px; }
  .btn { padding: 8px 13px; font-size: 12px; letter-spacing: .04em; }
  .thumb, .thumb__frame { width: 104px; }
  .thumb__frame { height: 104px; }
  .settings__label { min-width: 58px; }
  .section h2 { font-size: 20px; }
  .compare__stage { max-height: 320px; }
}

@media (max-width: 420px) {
  .strip__nav { font-size: 24px; padding: 4px 0; }
  .thumb, .thumb__frame { width: 88px; }
  .thumb__frame { height: 88px; }
}

/* 尊重系统的「减少动态效果」—— 竞品这一点也是空白 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   夜间模式
   主题值由 <head> 里的内联脚本在首次绘制前写到 <html data-theme>，
   所以这里只需覆盖变量，不会出现"先白后黑"的闪烁。
   ========================================================================== */
[data-theme="dark"] {
  --bg: #14171c;
  --surface: #1c2027;
  --surface-2: #23282f;
  --border: #2e343d;
  --border-strong: #3c434e;
  --text: #e6e9ee;
  --text-muted: #a4adbb;
  --text-faint: #7b8695;
  --primary: #4a8ae0;
  --primary-hover: #5d97e6;
  --primary-soft: #1d2a3d;
  --danger: #e2685e;
  --danger-hover: #ee7c72;
  --success: #46a768;
  --success-hover: #52b877;
  --success-soft: #1b2f22;
  --success-text: #7fd39a;
  --success-border: #2f5c3d;
  --dark: #39404e;
  --dark-hover: #474f60;
  --accent: #e08a45;
  --checker-a: #1a1e24;
  --checker-b: #262b33;
  --ghost: #1f242b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .5);
  color-scheme: dark;   /* 让原生控件与滚动条也变暗 */
}
/* 图片上的分割手柄：固定白色在深色背景上会刺眼，改用面板色 */
[data-theme="dark"] .compare__split { background: var(--surface); }
[data-theme="dark"] .compare__handle { background: var(--surface); }
/* 缩略图上的 -N% 角标压在照片上，两种主题下都保持浅底深字最清楚 */
[data-theme="dark"] .thumb__saving { background: rgba(255, 255, 255, .92); }

/* ==========================================================================
   左侧边栏 + 内容区
   工具切换只在左侧（卡片上方不再有标签页）。
   窄屏时侧边栏折成一条横向可滑动的列表，而不是抽屉 —— 抽屉要额外的
   展开/收起状态和焦点管理，收益不值这个复杂度，横向列表在手机上更好用。
   ========================================================================== */
.shell {
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  gap: 28px;
  max-width: calc(var(--content-width) + 214px + 28px);
  margin: 0 auto;
  padding: 0 var(--pad) 40px;
  align-items: start;
}
.sidebar {
  position: sticky; top: 66px;
  padding: 14px 0;
  border-right: 1px solid var(--border);
}
.sidebar__nav { display: block; }
.sidebar__item {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 7px 12px; margin: 0 6px 2px;
  border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.sidebar__item:hover { background: var(--surface-2); color: var(--text); }
/* 当前所在的工具：高亮 + 左侧色条 */
.sidebar__item.is-active {
  background: var(--primary-soft); color: var(--primary); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--primary);
}
.sidebar__away { font-size: 11px; opacity: .7; flex: none; }
.sidebar__item:hover .sidebar__away { opacity: 1; }

/* 窄屏：侧边栏变成顶部横向列表 */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 0; padding-bottom: 32px; }
  .sidebar {
    position: static; border-right: 0; border-bottom: 1px solid var(--border);
    padding: 0 0 10px; margin-bottom: 18px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .sidebar__nav { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
  .sidebar__item { margin: 0; padding: 6px 10px; font-size: 13px; }
  .sidebar__item.is-active { box-shadow: inset 0 -2px 0 var(--primary); }
  .sidebar__away { display: none; }
}

/* ---------- 主题开关 ---------- */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; cursor: pointer;
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 999px;
  font: inherit; font-size: 12px; line-height: 1;
  transition: background .15s, border-color .15s, color .15s;
}
.theme-toggle:hover { border-color: var(--border-strong); color: var(--text); }
.theme-toggle__icon { font-size: 13px; }
.theme-toggle__text { white-space: nowrap; }
/* 窄屏只留图标，避免把语言切换挤掉 */
@media (max-width: 640px) {
  .theme-toggle__text { display: none; }
  .theme-toggle { padding: 5px 8px; }
}

/* ---- 文章里的数据表格 ----
   外面套一层 .tablewrap 让窄屏可以横向滚动，而不是把整页撑宽。
   为什么加：实测 / 对比类文章要用表格呈现数据（也对搜索结果里的对比内容有利）。 */
.tablewrap { overflow-x: auto; margin: 18px 0; -webkit-overflow-scrolling: touch; }
.post table, .tablewrap table { border-collapse: collapse; width: 100%; font-size: 14px; }
.post th, .post td, .tablewrap th, .tablewrap td {
  border: 1px solid var(--border-strong); padding: 7px 11px; text-align: left;
  font-variant-numeric: tabular-nums;
}
.post thead th, .tablewrap thead th { background: var(--surface); font-weight: 600; }
.post tbody tr:nth-child(even), .tablewrap tbody tr:nth-child(even) { background: rgba(0, 0, 0, .015); }
[data-theme="dark"] .post tbody tr:nth-child(even),
[data-theme="dark"] .tablewrap tbody tr:nth-child(even) { background: rgba(255, 255, 255, .03); }
