:root {
  --brand: #2f6df6;
  --brand-ink: #1b3fb0;
  --brand-soft: #eaf0ff;
  --ink: #16202e;
  --ink-2: #47566a;
  --ink-3: #7c8ba1;
  --line: #e3e8ef;
  --bg: #ffffff;
  --bg-2: #f6f8fb;
  --bg-3: #eef2f7;
  --ok: #1f9d55;
  --warn: #b7791f;
  --err: #d64545;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-2: 0 8px 24px -6px rgba(16, 24, 40, .14);
  --max: 1240px;
  --tool-max: 760px;
  --gap: 20px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #6b9bff; --brand-ink: #a9c4ff; --brand-soft: #16233d;
    --ink: #eaeef5; --ink-2: #b3bdcc; --ink-3: #8492a5;
    --line: #26303f; --bg: #10151d; --bg-2: #151c26; --bg-3: #1b2330;
    --shadow-1: none; --shadow-2: 0 8px 24px -6px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 16px; line-height: 1.55; word-break: break-word;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, canvas, video { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(24px, 3.4vw, 34px); }
h2 { font-size: clamp(19px, 2.2vw, 23px); }
h3 { font-size: 17px; }
p { margin: 0 0 1em; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--bg); padding: 8px 12px; z-index: 99; border-radius: var(--radius-sm); }
.skip:focus { top: 8px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line);
}
.header-row { display: flex; align-items: center; gap: 14px; height: 62px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; color: var(--ink); letter-spacing: -.02em; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #7c4dff); color: #fff; display: grid; place-items: center; font-size: 16px; }
.header-nav { display: flex; gap: 4px; margin-left: 6px; }
.header-nav a { color: var(--ink-2); padding: 8px 11px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 500; }
.header-nav a:hover { background: var(--bg-3); color: var(--ink); text-decoration: none; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); height: 38px; min-width: 38px; padding: 0 10px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }

.search-panel { position: fixed; inset: 0; background: rgba(8, 12, 20, .45); display: grid; place-items: start center; padding: 8vh 16px 16px; z-index: 60; }
.search-box { width: min(660px, 100%); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); overflow: hidden; }
.search-box input { width: 100%; border: 0; padding: 16px 18px; font: inherit; font-size: 17px; background: transparent; color: var(--ink); outline: none; }
.search-results { max-height: min(58vh, 520px); overflow: auto; border-top: 1px solid var(--line); overscroll-behavior: contain; }
/* the title column is a real column now: `display:flex` with a long description squeezed
   "转 PDF" into two lines and made every CJK row look broken */
.search-results a { display: grid; grid-template-columns: minmax(104px, 200px) minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 10px 16px; color: var(--ink); border-bottom: 1px solid var(--bg-3); }
.search-results a b { font-weight: 600; }
.search-results a:hover { background: var(--bg-2); text-decoration: none; }
.search-results small { color: var(--ink-3); }
/* category heading between the groups, and it is itself the link to that category page */
.search-results .search-cat { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; position: sticky; top: 0; background: var(--bg-2); color: var(--ink-2); padding: 7px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.search-results .search-cat b { font-weight: 700; }
.search-results .search-cat span { color: var(--ink-3); font-size: 12px; }
.search-browse a, .search-browse .search-cat { padding-block: 8px; }
.search-empty { padding: 16px; color: var(--ink-2); }

/* language menu */
.lang-menu { position: absolute; right: 12px; top: 64px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 6px; display: grid; gap: 2px; z-index: 50; min-width: 176px; max-height: 70vh; overflow: auto; }
.lang-menu button { text-align: left; border: 0; background: none; font: inherit; padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; color: var(--ink-2); display: flex; justify-content: space-between; gap: 10px; }
.lang-menu button:hover { background: var(--bg-2); color: var(--ink); }
.lang-menu button[aria-current="true"] { color: var(--brand); font-weight: 600; }
.lang-menu .why { padding: 8px 10px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--bg-3); }

/* ---------- ads ---------- */
/* One native slot renderer (templates.mjs adSlot): DOM exists only when ENABLE_ADS is on AND the
   AdSense client+slot ids are filled — otherwise nothing renders, never a placeholder box. Each slot
   keeps a >=24px safe gap above/below so a phone tap on Copy/Download/input never lands on an ad, and
   is width-capped so a responsive unit can never overflow its column. No fixed/edge rails, no popups. */
.ad-slot { margin: 24px auto; max-width: 100%; overflow: hidden; text-align: center; }
.ad-slot ins.adsbygoogle { max-width: 100%; }
.ad-tag { font-size: 11px; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; margin: 0 0 6px; }
/* the in-content unit sits directly under the tool panel: widen the tap-safe gap on both sides */
.tool-main > .ad-slot, .ad-inContent { margin-top: 28px; margin-bottom: 28px; }
/* legal pages are a single readable column (no sidebar); the optional ad sits below the prose */
.legal-prose { max-width: 760px; }

/* ---------- home ---------- */
.hero { padding: 38px 0 26px; }
.hero h1 { max-width: 22ch; }
.hero p.sub { max-width: 62ch; color: var(--ink-2); font-size: clamp(16px, 1.5vw, 18px); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.trust { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 18px; color: var(--ink-2); font-size: 14px; }
.trust span { display: inline-flex; gap: 7px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--brand-soft); color: var(--brand-ink); border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600; }

.section { padding: 22px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.section-head a { font-size: 14px; white-space: nowrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.tool-card { display: flex; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); box-shadow: var(--shadow-1); color: var(--ink); align-items: flex-start; }
.tool-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); transform: translateY(-1px); transition: .16s; }
.tool-card .ico { font-size: 20px; line-height: 1.3; flex: none; width: 34px; height: 34px; display: grid; place-items: center; background: var(--bg-2); border-radius: 9px; }
.tool-card b { display: block; font-size: 15px; font-weight: 600; }
.tool-card small { color: var(--ink-3); font-size: 12.5px; line-height: 1.4; display: block; margin-top: 2px; }
.tool-card .hot { margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); font-weight: 700; }

.cat-block { margin-bottom: 26px; }
.cat-block h2 { display: flex; align-items: center; gap: 8px; font-size: 20px; }
.cat-block .cat-tag { color: var(--ink-2); font-size: 14px; margin: -6px 0 12px; }
.home-cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 26px; align-items: start; }
.why-list { display: grid; gap: 12px; }
.why-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--bg-2); }
.why-item h3 { margin: 0 0 4px; font-size: 15px; }
.why-item p { margin: 0; color: var(--ink-2); font-size: 14px; }
.faq-item { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq-item summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; gap: 8px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: "+"; color: var(--brand); font-weight: 700; }
.faq-item[open] summary::before { content: "–"; }
.faq-item p { margin: 8px 0 0; color: var(--ink-2); }

/* ---------- tool page ---------- */
.tool-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; padding: 22px 0 8px; }
.tool-main { min-width: 0; max-width: 860px; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--ink-3); margin: 14px 0 6px; }
.breadcrumb a { color: var(--ink-3); }
.breadcrumb span::before { content: "/"; margin: 0 6px; color: var(--line); }
.tool-head p.lede { color: var(--ink-2); font-size: 17px; max-width: 70ch; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }
.badge { font-size: 12.5px; color: var(--ink-2); background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; display: inline-flex; gap: 6px; align-items: center; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); box-shadow: var(--shadow-1); padding: 18px; margin: 18px 0; }
.panel + .panel { margin-top: 0; }
.drop { border: 2px dashed color-mix(in srgb, var(--brand) 40%, var(--line)); border-radius: var(--radius); background: var(--bg-2); padding: 30px 18px; text-align: center; cursor: pointer; color: var(--ink-2); }
.drop:hover, .drop.over { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.drop .big { font-size: 30px; display: block; margin-bottom: 6px; }
.drop .hint { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.file-list { display: grid; gap: 8px; margin: 14px 0 0; }
.file-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; background: var(--bg-2); font-size: 14px; }
.file-row .nm { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .sz { color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 13px; }
.file-row .thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--bg-3); flex: none; }
.file-row button { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 17px; padding: 2px 6px; border-radius: 6px; }
.file-row button:hover { color: var(--err); background: var(--bg-3); }
.file-row[draggable="true"] { cursor: grab; }
.file-row.dragging { opacity: .4; }

.controls { display: flex; flex-wrap: wrap; gap: 14px 18px; margin: 16px 0 4px; align-items: flex-end; }
.field { display: grid; gap: 5px; min-width: 130px; }
.field label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.field .note { font-size: 12px; color: var(--ink-3); }
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 11px; width: 100%;
}
input[type="range"] { accent-color: var(--brand); width: 160px; }
input[type="checkbox"] { accent-color: var(--brand); width: 16px; height: 16px; }
textarea { min-height: 150px; resize: vertical; font-family: var(--mono); font-size: 13.5px; line-height: 1.5; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-2); }
.btn { font: inherit; font-weight: 600; border-radius: var(--radius-sm); padding: 10px 16px; cursor: pointer; border: 1px solid var(--brand); background: var(--brand); color: #fff; display: inline-flex; gap: 8px; align-items: center; justify-content: center; }
.btn:hover:not(:disabled) { background: var(--brand-ink); border-color: var(--brand-ink); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { background: var(--bg-2); color: var(--ink); border-color: var(--ink-3); }
.btn.big { padding: 13px 22px; font-size: 16px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }

.out { margin-top: 16px; display: grid; gap: 12px; }
.stat { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: baseline; padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.stat b { font-size: 22px; letter-spacing: -.02em; }
.stat .lbl { color: var(--ink-3); font-size: 13px; }
.stat .delta { color: var(--ok); font-weight: 700; }
.result-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--bg-2); }
.result-card pre, .result-card code { font-family: var(--mono); font-size: 13px; white-space: pre-wrap; word-break: break-word; margin: 0; max-height: 420px; overflow: auto; display: block; }
.output-box { min-height: 120px; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.preview-grid figure { margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-2); }
.preview-grid img { display: block; width: 100%; }
.preview-grid figcaption { font-size: 12px; color: var(--ink-3); padding: 5px 8px; }
.note { font-size: 13.5px; color: var(--ink-2); background: var(--bg-2); border-left: 3px solid var(--line); padding: 10px 13px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.note.err { border-color: var(--err); color: var(--err); background: color-mix(in srgb, var(--err) 8%, var(--bg)); }
.note.ok { border-color: var(--ok); }
.bar { height: 8px; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }
.diff-view { font-family: var(--mono); font-size: 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: auto; }
.diff-view div { padding: 2px 10px; white-space: pre-wrap; }
.diff-add { background: color-mix(in srgb, var(--ok) 16%, var(--bg)); }
.diff-del { background: color-mix(in srgb, var(--err) 16%, var(--bg)); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 62px; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; background: var(--bg); }
.swatch i { display: block; height: 40px; }
.swatch span { font-size: 11px; display: block; padding: 3px; font-family: var(--mono); }
.match { background: color-mix(in srgb, var(--brand) 26%, var(--bg)); border-radius: 3px; }
.speech { display: grid; gap: 10px; }
.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 6px 12px; align-items: center; }
.kv .k { font-size: 13px; color: var(--ink-2); }

.prose h2 { margin-top: 30px; }
.prose h3 { margin-top: 20px; }
.prose ol, .prose ul { padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose .steps li { padding-left: 4px; }
.skeleton { color: var(--ink-3); }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }

.side { position: sticky; top: 74px; display: grid; gap: 18px; }
.side .panel { margin: 0; }
.side-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 0 0 10px; font-weight: 700; }
.side-list { display: grid; gap: 2px; }
.side-list a { display: flex; gap: 9px; align-items: center; padding: 8px 9px; border-radius: var(--radius-sm); color: var(--ink-2); font-size: 14px; }
.side-list a:hover { background: var(--bg-2); color: var(--ink); text-decoration: none; }
.side-list a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }

/* ---------- footer / legal ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-2); margin-top: 44px; padding: 30px 0 20px; font-size: 14px; }
.foot-cols { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 24px; }
.foot-cols h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 0 0 10px; }
.foot-cols a { display: block; color: var(--ink-2); padding: 3px 0; }
.foot-cols a:hover { color: var(--ink); }
.foot-note { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 10px 18px; justify-content: space-between; }

.consent-bar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 70; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; max-width: var(--max); margin: 0 auto; }
.consent-bar p { margin: 0; flex: 1 1 320px; font-size: 14px; color: var(--ink-2); }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 80; box-shadow: var(--shadow-2); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .tool-layout, .home-cols { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .foot-cols { grid-template-columns: 1fr 1fr; }
  .header-nav { display: none; }
  .header-nav.open { display: flex; position: absolute; left: 0; right: 0; top: 62px; background: var(--bg); border-bottom: 1px solid var(--line); flex-direction: column; padding: 8px 16px 14px; }
}
@media (max-width: 620px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .foot-cols { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .panel { padding: 14px; }
  .drop { padding: 22px 12px; }
  /* on a phone the panel was 8vh of padding plus a 56vh list showing five rows of a 49-tool
     catalogue: it now takes the screen, and rows stack so a long description cannot squash
     the tool name */
  .search-panel { padding: 8px; place-items: start stretch; }
  .search-box { width: 100%; }
  .search-box input { padding: 13px 14px; font-size: 16px; }
  .search-results { max-height: calc(100vh - 92px); }
  .search-results a { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 9px 14px; }
  .search-results a small { font-size: 12px; }
}
@media print { .site-header, .site-footer, .ad-slot, .side, .consent-bar { display: none !important; } }
