:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #15171a;
  --muted: #5d6470;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --on-accent: #ffffff;
  --ok: #16703c;
  --ok-soft: #e7f6ed;
  --warn: #a15c00;
  --warn-soft: #fff4e0;
  --err: #c62a2f;
  --err-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --border: #2a2f39;
    --text: #e9ecf1;
    --muted: #9aa3b2;
    --accent: #8b85ff;
    --accent-hover: #a29dff;
    --accent-soft: #24234a;
    --on-accent: #12112a;
    --ok: #4cc685;
    --ok-soft: #13291e;
    --warn: #f0b252;
    --warn-soft: #2c2210;
    --err: #ff6b70;
    --err-soft: #331618;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, canvas, video, audio { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); letter-spacing: -.02em; }
h2 { font-size: 1.35rem; margin-top: 1.6em; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
code, pre, textarea.mono, .mono { font-family: var(--mono); font-size: .92em; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 860px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; gap: 20px; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo svg { width: 28px; height: 28px; }
.main-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a {
  padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-size: .95rem;
}
.main-nav a:hover, .main-nav a.active { background: var(--surface-2); color: var(--text); text-decoration: none; }
.lang-switch select {
  font: inherit; font-size: .9rem; padding: 5px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
@media (max-width: 720px) {
  .site-header .wrap { gap: 10px; }
  .logo span { display: none; }
}

/* Hero */
.hero { padding: 48px 0 28px; text-align: center; }
.hero p.sub { color: var(--muted); font-size: 1.12rem; max-width: 680px; margin: 0 auto 22px; }
.badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 22px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: .88rem;
  background: var(--ok-soft); color: var(--ok); font-weight: 500;
}
.badge svg { width: 15px; height: 15px; }
.search {
  width: 100%; max-width: 560px; padding: 13px 18px; font: inherit; font-size: 1.05rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
}
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Tool grid */
.cat-section { margin: 34px 0; }
.cat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.cat-head h2 { margin: 0; }
.cat-head a { font-size: .92rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card {
  display: flex; gap: 12px; align-items: flex-start; padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover { text-decoration: none; border-color: var(--cat, var(--accent)); box-shadow: var(--shadow); transform: translateY(-1px); }
.card strong { display: block; font-size: 1rem; margin-bottom: 2px; }
.card span.d { display: block; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.ico {
  flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--cat, var(--accent)) 14%, transparent); color: var(--cat, var(--accent));
}
.ico svg { width: 21px; height: 21px; }
.empty-search { text-align: center; color: var(--muted); padding: 30px 0; display: none; }

/* Tool page */
.crumbs { font-size: .9rem; color: var(--muted); margin: 18px 0 10px; }
.crumbs a { color: var(--muted); }
.tool-head { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.tool-head .ico { width: 48px; height: 48px; border-radius: 12px; }
.tool-head .ico svg { width: 26px; height: 26px; }
.tool-head h1 { margin: 0; }
.lead { color: var(--muted); font-size: 1.06rem; margin: 8px 0 14px; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px; box-shadow: var(--shadow); margin: 18px 0 8px;
}
@media (max-width: 600px) { .panel { padding: 16px; } }
.privacy-note { font-size: .88rem; color: var(--muted); display: flex; align-items: center; gap: 6px; margin: 6px 0 0; }
.privacy-note svg { width: 15px; height: 15px; color: var(--ok); flex: none; }

/* Dropzone */
.dropzone {
  position: relative; border: 2px dashed var(--border); border-radius: 14px; padding: 34px 16px;
  text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone .dz-icon { width: 42px; height: 42px; color: var(--accent); margin-bottom: 6px; }
.dropzone .dz-title { font-weight: 600; font-size: 1.05rem; }
.dropzone .dz-hint { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.dropzone.compact { padding: 14px; }
.dropzone.compact .dz-icon { display: none; }

/* Form controls */
.controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin: 18px 0; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: .92rem; }
.field > span { color: var(--muted); font-weight: 500; }
.field.row { flex-direction: row; align-items: center; gap: 8px; }
input[type=text], input[type=number], input[type=url], input[type=password], input[type=time], input[type=datetime-local], select, textarea {
  font: inherit; font-size: .95rem; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: .95rem; padding: 10px 18px; border-radius: 10px;
  border: 1px solid transparent; background: var(--accent); color: var(--on-accent); cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.small { padding: 6px 11px; font-size: .86rem; border-radius: 8px; }
.btn.big { padding: 13px 26px; font-size: 1.05rem; }
.btn svg { width: 17px; height: 17px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.icon-btn {
  width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; padding: 0;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn:disabled { opacity: .35; cursor: default; background: var(--surface); }
.icon-btn svg { width: 16px; height: 16px; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  font: inherit; font-size: .9rem; border: 0; background: transparent; color: var(--muted);
  padding: 6px 13px; border-radius: 8px; cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 600; }

/* Status / progress */
.status { margin-top: 14px; padding: 10px 14px; border-radius: 10px; font-size: .93rem; display: none; }
.status.show { display: block; }
.status.info { background: var(--accent-soft); color: var(--text); }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.err { background: var(--err-soft); color: var(--err); }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 12px; display: none; }
.progress.show { display: block; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* File list */
.file-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-list li {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: var(--surface-2); border-radius: 10px; font-size: .93rem;
}
.file-list .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .fmeta { color: var(--muted); font-size: .86rem; white-space: nowrap; }
.file-list .thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--border); flex: none; }
.gain { color: var(--ok); font-weight: 600; }
.loss { color: var(--warn); font-weight: 600; }

.results { margin-top: 18px; }
.results h3 { margin-bottom: 8px; }

/* Page thumbnails (PDF) */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; margin-top: 16px; }
.page-card {
  position: relative; background: var(--surface-2); border: 2px solid transparent; border-radius: 10px;
  padding: 8px; text-align: center; cursor: grab; user-select: none;
}
.page-card.dragging { opacity: .4; }
.page-card.drop-target { border-color: var(--accent); }
.page-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.page-card canvas { display: block; margin: 0 auto; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); background: #fff; transition: transform .2s; }
.page-card .pn { font-size: .82rem; color: var(--muted); margin-top: 6px; }
.page-card .tools { display: flex; justify-content: center; gap: 4px; margin-top: 6px; }

/* Two-column editors */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
.out-box {
  min-height: 140px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 14px 0; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 1.35rem; }
.stat span { color: var(--muted); font-size: .85rem; }
mark { background: #ffe066; color: #111; border-radius: 3px; padding: 0 1px; }
mark.alt { background: #a5d8ff; }
.diff-add { background: color-mix(in srgb, var(--ok) 22%, transparent); }
.diff-del { background: color-mix(in srgb, var(--err) 22%, transparent); text-decoration: line-through; }
table.kv { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.kv td, table.kv th { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; word-break: break-all; }
table.kv th { color: var(--muted); font-weight: 500; width: 32%; }
.preview-stage { background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 20px 20px; border-radius: 10px; padding: 10px; text-align: center; }
.hidden { display: none !important; }

/* Content below the tool */
.howto ol { padding-left: 1.3em; }
.howto li { margin-bottom: .4em; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; color: var(--muted); }
.prose { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; margin: 24px 0; }
.prose h2:first-child { margin-top: 0; }
.prose li { margin-bottom: .35em; }

/* Footer */
.site-footer { margin-top: 60px; border-top: 1px solid var(--border); background: var(--surface); padding: 30px 0; font-size: .92rem; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 16px; }
.site-footer a { color: var(--muted); }
