*{margin:0;padding:0;box-sizing:border-box}
:root{--bg:#f7f8fa;--card:#fff;--primary:#2563eb;--primary-hover:#1d4ed8;--secondary:#6b7280;--secondary-hover:#4b5563;--border:#e5e7eb;--text:#1f2937;--heading:#111827;--muted:#6b7280;--error:#dc2626;--success:#16a34a;--code-bg:#fafbfc}
html{font-size:16px}
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;background:var(--bg);color:var(--text);line-height:1.65}
.container{max-width:1100px;margin:0 auto;padding:24px 20px 60px}
.brand-header{display:flex;align-items:center;margin:12px 0 24px}
.brand-header a{font-size:18px;font-weight:700;color:var(--primary);text-decoration:none}
.brand-header a:hover{text-decoration:underline}
.brand-header .brand-desc{color:#666;margin-left:8px}
.back-link{display:inline-block;margin-bottom:20px;color:var(--primary);text-decoration:none;font-size:14px;font-weight:500}
.back-link:hover{text-decoration:underline}
h1{font-size:28px;line-height:1.2;margin-bottom:12px;color:var(--heading);font-weight:700}
h2{font-size:20px;line-height:1.3;margin:28px 0 12px;color:var(--heading);font-weight:600}
h3{font-size:16px;margin-bottom:6px;color:var(--heading)}
p{margin-bottom:12px}
.desc{color:var(--muted);margin-bottom:24px;font-size:15px}
.privacy-badge{display:inline-block;background:#ecfdf5;color:#065f46;font-size:12px;padding:2px 10px;border-radius:12px;font-weight:500;margin-left:8px;vertical-align:middle}
.tool-area{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:16px}
.tool-area.single{grid-template-columns:1fr}
.pane{background:var(--card);border:1px solid var(--border);border-radius:8px;padding:14px;box-shadow:0 1px 2px rgba(0,0,0,.04);transition:box-shadow .15s}
.pane:hover{box-shadow:0 2px 6px rgba(0,0,0,.06)}
.pane label{display:block;font-size:13px;font-weight:600;margin-bottom:8px;color:var(--secondary);text-transform:uppercase;letter-spacing:.03em}
textarea,.expr-input{width:100%;min-height:280px;font-family:'Consolas','Monaco','Courier New',monospace;font-size:13px;line-height:1.5;padding:10px;border:1px solid var(--border);border-radius:6px;resize:vertical;background:var(--code-bg);color:var(--text);outline:none;transition:border-color .15s}
textarea:focus,.expr-input:focus{border-color:var(--primary)}
.expr-input{min-height:48px;resize:none}
#output{background:var(--code-bg);color:#0f172a}
.tree-output{min-height:280px;max-height:480px;overflow:auto;padding:10px;background:var(--code-bg);border:1px solid var(--border);border-radius:6px;font-family:'Consolas','Monaco','Courier New',monospace;font-size:13px;line-height:1.6}
.tree-output details{margin-left:8px}
.tree-output details>summary{cursor:pointer;padding:1px 0;user-select:none}
.tree-output ul,.tree-output ol{list-style:none;margin-left:12px;padding-left:8px;border-left:1px dashed var(--border)}
.tree-output .key{color:#7c3aed;font-weight:600}
.tree-output .string{color:#16a34a}
.tree-output .number{color:#2563eb}
.tree-output .boolean{color:#ea580c}
.tree-output .null{color:#9ca3af}
.tree-output .object,.tree-output .array{color:var(--muted);font-size:12px;margin-left:4px}
.buttons{display:flex;gap:12px;align-items:center;margin-bottom:16px;flex-wrap:wrap}
button{padding:10px 24px;border:none;border-radius:6px;font-size:14px;font-weight:600;cursor:pointer;transition:background .15s;font-family:inherit}
.btn-primary{background:var(--primary);color:#fff}
.btn-primary:hover{background:var(--primary-hover)}
.btn-secondary{background:var(--secondary);color:#fff}
.btn-secondary:hover{background:var(--secondary-hover)}
#status{font-size:13px;margin-left:8px;font-weight:500}
.status-ok{color:var(--success)}
.status-error{color:var(--error)}
.related{display:flex;flex-wrap:wrap;gap:10px;margin-top:8px}
.related a{display:inline-block;padding:8px 14px;background:#fff;border:1px solid var(--border);border-radius:6px;color:var(--primary);text-decoration:none;font-size:13px;font-weight:500;transition:box-shadow .15s,border-color .15s}
.related a:hover{box-shadow:0 2px 6px rgba(0,0,0,.08);border-color:var(--primary)}
.tools-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:16px;margin-top:24px}
.tool-card{display:block;padding:20px;background:#fff;border:1px solid var(--border);border-radius:8px;text-decoration:none;color:var(--text);transition:box-shadow .15s,transform .15s,border-color .15s}
.tool-card:hover{box-shadow:0 4px 12px rgba(0,0,0,.08);transform:translateY(-2px);border-color:var(--primary)}
.tool-card h3{color:var(--primary);margin-bottom:6px;font-size:16px;font-weight:600}
.tool-card p{font-size:13px;color:var(--muted);margin:0;line-height:1.5}
.feature-list{padding-left:20px}
.feature-list li{margin-bottom:6px}
.feature-list li::marker{color:var(--primary)}
code{background:var(--code-bg);padding:2px 6px;border-radius:4px;font-size:13px;font-family:'Consolas','Monaco',monospace;border:1px solid var(--border)}
pre{background:var(--code-bg);padding:12px;border-radius:6px;overflow-x:auto;border:1px solid var(--border);margin-bottom:12px}
pre code{background:none;border:none;padding:0}
footer{margin-top:40px;padding-top:20px;border-top:1px solid var(--border);color:var(--muted);font-size:13px;text-align:center}
@media (max-width:768px){.tool-area{grid-template-columns:1fr}h1{font-size:24px}h2{font-size:18px}.container{padding:16px 12px 40px}textarea,.expr-input{min-height:200px}.tree-output{max-height:320px}.tools-grid{grid-template-columns:1fr}.buttons{flex-direction:column;align-items:stretch}button{width:100%}}

.ad-slot{min-height:15px;margin-top:40px;margin-bottom:32px}

/* ===== Floating topbar + language dropdown ===== */
.topbar{position:sticky;top:0;z-index:100;display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:10px 16px;background:#fff;border-bottom:1px solid #e4e8f0;box-shadow:0 1px 4px rgba(20,30,60,.05);}
.topbar a{color:#3b82f6;text-decoration:none;font-size:13px;font-weight:600;}
.topbar a:hover{text-decoration:underline;}
.topbar .divider{color:#d7deea;font-size:13px;}
.topbar .brand-name{font-weight:700;font-size:15px;color:#1f2430;letter-spacing:.3px;text-decoration:none;}
.topbar .brand-name span{color:#3b82f6;}
.spacer{flex:1;}
.lang-dropdown{position:relative;}
.lang-dropdown summary{list-style:none;cursor:pointer;font-size:13px;font-weight:600;color:#39435a;background:#fff;border:1px solid #dde3ee;border-radius:9px;padding:7px 12px;display:inline-flex;align-items:center;gap:6px;}
.lang-dropdown summary::-webkit-details-marker{display:none;}
.lang-dropdown summary::after{content:'\25BE';font-size:10px;color:#8b93a7;margin-left:2px;}
.lang-menu{position:absolute;right:0;top:calc(100% + 6px);background:#fff;border:1px solid #e4e8f0;border-radius:9px;box-shadow:0 6px 18px rgba(20,30,60,.12);overflow:hidden;min-width:140px;z-index:200;display:flex;flex-direction:column;}
.lang-menu a{display:block;padding:9px 14px;color:#39435a;text-decoration:none;font-size:13px;font-weight:500;}
.lang-menu a:hover{background:#f4f7fd;color:#3b82f6;}
.lang-menu a[aria-current="true"]{background:#eef4ff;color:#2563eb;font-weight:700;}
@media(max-width:768px){.topbar{padding:8px 12px;}.topbar .brand-name{font-size:14px;}}

/* ===== PDF Tool Specific Styles ===== */

/* Dropzone - file upload area */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: #fafbfc;
  margin-bottom: 16px;
}
.dropzone:hover {
  border-color: var(--primary);
  background: #f0f5ff;
}
.dropzone.dragover {
  border-color: var(--primary);
  background: #eef4ff;
}
.dropzone p {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
}

/* File list */
.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
.file-item .drag-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 18px;
  user-select: none;
}
.file-item .file-icon {
  color: #dc2626;
  font-size: 20px;
}
.file-item .file-name {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-item .file-pages {
  font-size: 12px;
  color: var(--muted);
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.file-item .btn-remove {
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
}
.file-item .btn-remove:hover {
  color: #b91c1c;
}
.file-item .btn-move {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 8px;
  border-radius: 4px;
}

/* Quality selector - for compress tool */
.quality-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.quality-option {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  text-align: center;
  transition: border-color .2s, background .2s;
}
.quality-option:hover {
  border-color: var(--primary);
}
.quality-option:has(input:checked) {
  border-color: var(--primary);
  background: #eef4ff;
}
.quality-option input[type="radio"] {
  display: none;
}
.quality-option .quality-label {
  font-weight: 600;
  font-size: 15px;
  color: var(--heading);
  display: block;
}
.quality-option .quality-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* Preview grid - thumbnails */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.preview-thumb {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}
.preview-thumb img {
  width: 100%;
  display: block;
}
.preview-thumb .thumb-label {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 4px;
  background: #f9fafb;
}
.preview-thumb .thumb-download {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255,255,255,.9);
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--primary);
}

/* Progress bar */
.progress-bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
  display: none;
}
.progress-bar.active {
  display: block;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width .3s;
  width: 0%;
}

/* Size compare - compress tool */
.size-compare {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.size-compare .size-original {
  color: var(--muted);
}
.size-compare .size-arrow {
  color: var(--muted);
}
.size-compare .size-compressed {
  color: var(--success);
  font-weight: 600;
}
.size-compare .size-reduction {
  background: #dcfce7;
  color: #166534;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}

/* Parameter rows - watermark etc */
.param-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.param-row label {
  min-width: 120px;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.param-row input[type="text"],
.param-row input[type="number"],
.param-row input[type="color"],
.param-row select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
}
.param-row input[type="range"] {
  flex: 1;
}

/* Mode radio group - split tool */
.mode-group {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.mode-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.mode-option.active {
  border-color: var(--primary);
  background: #eef4ff;
}

/* Loading overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  font-size: 15px;
  color: var(--primary);
}

/* Mobile responsive additions */
@media (max-width:768px) {
  .dropzone { min-height: 120px; }
  .dropzone p { font-size: 14px; padding: 0 12px; text-align: center; }
  .file-item { padding: 10px 12px; flex-wrap: wrap; }
  .file-item .file-name { font-size: 13px; min-width: 0; flex: 1 1 60%; }
  .file-item .drag-handle { font-size: 16px; padding: 4px; }
  .file-item .btn-remove { font-size: 20px; padding: 6px 10px; }
  .preview-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .quality-selector { flex-direction: column; }
  .mode-group { flex-direction: column; }

  .param-row { flex-direction: column; align-items: stretch; gap: 6px; margin-bottom: 14px; }
  .param-row label { min-width: auto; font-size: 13px; }
  .param-row input[type="text"],
  .param-row input[type="number"],
  .param-row select {
    padding: 10px 12px;
    font-size: 16px;
    border-radius: 8px;
  }
  .param-row input[type="range"] { height: 40px; }
  .param-row input[type="color"] { height: 44px; width: 100%; border-radius: 8px; padding: 4px; }

  .wm-layout { flex-direction: column; gap: 16px; }
  .wm-preview { display: flex; justify-content: center; }
  .wm-preview canvas { max-width: 180px; border-radius: 6px; }

  .buttons button { padding: 12px; font-size: 15px; }
}

/* Chinese text adjustments */
:lang(zh) h1 { letter-spacing: 0.02em; }
:lang(zh) .desc { line-height: 1.7; }

/* Watermark preview layout */
.wm-layout { display: flex; gap: 24px; align-items: flex-start; margin: 16px 0; }
.wm-params { flex: 1; min-width: 0; }
.wm-preview { flex-shrink: 0; text-align: center; }
.wm-preview canvas { border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,.08); max-width: 200px; height: auto; }
@media (max-width: 768px) { .wm-layout { flex-direction: column; } }

/* ===== Batch-2 Tool Styles ===== */

/* Signature pad */
.signature-pad {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  display: inline-block;
  touch-action: none;
  max-width: 100%;
  margin-bottom: 12px;
}
.signature-pad canvas {
  display: block;
  width: 100%;
  max-width: 400px;
  height: auto;
  cursor: crosshair;
}

/* Thumbnail grid cards (delete/rearrange) */
.thumb {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  background: var(--card);
  cursor: grab;
  user-select: none;
}
.thumb img {
  width: 100%;
  height: auto;
  display: block;
}
.thumb .btn-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}
.thumb.drag-over {
  border-color: var(--primary);
  opacity: 0.5;
}
.thumb .page-num {
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* OCR / text output areas */
.ocr-output,
#ocr-output,
#text-output {
  width: 100%;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  resize: vertical;
  min-height: 200px;
  margin-bottom: 12px;
}

/* Form field labels */
.field-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

/* Responsive */
@media (max-width: 768px) {
  .preview-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .signature-pad canvas { max-width: 100%; }
}
