/* ============================================================
   设计令牌
   布局节奏参考了同品类的通用做法（工具卡靠上、横向缩略图条、独立对比卡），
   但这里的每一个色值、间距、组件都是我们自己写的。
   ============================================================ */
: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);
  --pad: 20px;
  --row-gap: 14px;
}

*, *::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;
}
.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; }

.tabs { display: flex; align-items: flex-end; gap: 3px; padding-left: 6px; }
.tab {
  appearance: none; border: 0; cursor: pointer;
  padding: 9px 20px; font: inherit; font-size: 14px;
  background: var(--surface-2); color: var(--text-muted);
  border-radius: var(--radius) var(--radius) 0 0;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--accent); font-weight: 600; }
.tab--right { margin-left: auto; }

.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: #fcfcfd;
}
/* 显式 display 会盖掉 [hidden] 的 display:none —— 必须补这一条，否则放了图拖放区也不消失 */
.drop[hidden] { display: none; }
.drop.is-over { border-color: var(--primary); background: #f4f8ff; }
.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); }

/* ---------- 动作行 ---------- */
.actions { display: flex; justify-content: center; gap: 10px; }

/* ---------- 设置区 ---------- */
.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; }

/* ---------- 压缩算法选择 ---------- */
/* 标签独占一行，卡片区占满整宽 —— 否则 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); }
/* :has() 在 Safari 15.4+ / Chrome 105+ / Firefox 121+ 可用，我们的基线是 Safari 16.4 */
.algo:has(input:checked) { border-color: var(--primary); background: #f4f8ff; }
.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: #e2f4e7; color: #1e7a3c; border: 1px solid #bfe5cb;
  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: var(--surface-2);
}
.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__actions .btn[hidden] { display: none; }

/* ============================================================
   内容区
   ============================================================ */
.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; }

/* ============================================================
   窄屏：保持同一操作顺序，只是缩小与堆叠
   ============================================================ */
@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;
  }
}
