/* ============================================================
   PDF 工具箱 — 设计系统（简洁 / 高大上）
   ============================================================ */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fbfbfe;
  --border: #e8eaf2;
  --border-strong: #d7dbe8;
  --text: #1a1d29;
  --text-2: #5b6273;
  --text-3: #939bb0;
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-d: #4f46e5;
  --primary-soft: #eef0ff;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --success: #16a34a;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05), 0 2px 8px rgba(16,24,40,.05);
  --shadow: 0 4px 12px rgba(16,24,40,.06), 0 16px 40px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(79,70,229,.18);
  --maxw: 1160px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
.icon { display: inline-block; vertical-align: middle; flex: none; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.78);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner { display: flex; align-items: center; gap: 20px; height: 66px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.12rem; }
.brand__mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--grad); color: #fff; box-shadow: var(--shadow-lg);
}
.brand--sm .brand__mark { width: 30px; height: 30px; border-radius: 9px; }
.brand--sm { font-size: 1rem; }
.site-nav { display: flex; gap: 4px; margin-left: 12px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  padding: 8px 13px; border-radius: 9px; color: var(--text-2); font-weight: 600; font-size: .92rem;
  white-space: nowrap; transition: .18s;
}
.site-nav a:hover { background: var(--primary-soft); color: var(--primary-d); }
.site-header__cta { margin-left: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 11px; border: 1px solid transparent;
  font-weight: 700; font-size: .95rem; cursor: pointer; transition: .18s; white-space: nowrap;
  font-family: inherit; line-height: 1;
}
.btn--primary { background: var(--grad); color: #fff; box-shadow: var(--shadow-lg); }
.btn--primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn--ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--ghost:hover { border-color: var(--primary); color: var(--primary-d); }
.btn--soft { background: var(--primary-soft); color: var(--primary-d); }
.btn--soft:hover { background: #e3e6ff; }
.btn--sm { padding: 8px 14px; font-size: .85rem; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; filter: none !important; }
.btn--block { width: 100%; }

/* ---------- Hero (home) ---------- */
.hero { padding: 64px 0 40px; text-align: center; }
.hero__badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-d); font-weight: 700; font-size: .82rem; margin-bottom: 20px;
}
.hero__title { font-size: clamp(2rem, 4.5vw, 3.2rem); line-height: 1.1; }
.hero__title .grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero__sub { margin: 18px auto 0; max-width: 620px; color: var(--text-2); font-size: 1.05rem; }
.hero__stats { display: flex; gap: 28px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.hero__stat { text-align: center; }
.hero__stat b { font-size: 1.5rem; display: block; }
.hero__stat span { color: var(--text-3); font-size: .85rem; }

/* ---------- Category + Tool grid ---------- */
.section { padding: 26px 0 8px; scroll-margin-top: 84px; }
.section__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.section__head h2 { font-size: 1.4rem; }
.section__head p { color: var(--text-3); margin: 0; font-size: .92rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 18px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; transition: .2s; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 12px; overflow: hidden;
}
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius); pointer-events: none;
  background: radial-gradient(120% 120% at 100% 0%, rgba(99,102,241,.08), transparent 55%);
  opacity: 0; transition: .25s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card:hover::after { opacity: 1; }
.tool-icon {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-d); font-size: 22px;
}
.tool-icon--lg { width: 60px; height: 60px; border-radius: 16px; font-size: 28px; }
.card__title { font-size: 1.06rem; font-weight: 700; }
.card__desc { color: var(--text-2); font-size: .9rem; flex: 1; }
.card .tag-row { display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  font-size: .72rem; font-weight: 600; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); padding: 3px 9px; border-radius: 999px;
}
.tool-tags { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Tool hero (inner pages) ---------- */
.tool-hero { padding: 34px 0 8px; }
.back-link { color: var(--text-3); font-size: .9rem; font-weight: 600; }
.back-link:hover { color: var(--primary-d); }
.tool-hero__head { display: flex; gap: 18px; align-items: center; margin-top: 14px; }
.tool-hero__title { font-size: 1.8rem; }
.tool-hero__desc { color: var(--text-2); margin: 6px 0 0; }

/* ---------- Panel / card content ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow-sm); margin: 22px 0 40px;
}
.panel + .panel { margin-top: 0; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.row--between { justify-content: space-between; }
.muted { color: var(--text-3); }
.hint { font-size: .86rem; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }

/* ---------- Dropzone ---------- */
.dropzone {
  position: relative; border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); padding: 34px 20px; text-align: center; cursor: pointer;
  transition: .2s; color: var(--text-2);
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-d); }
.dropzone__icon { width: 52px; height: 52px; border-radius: 14px; display: inline-grid; place-items: center; background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); margin-bottom: 12px; }
.dropzone__title { font-weight: 700; color: var(--text); }
.dropzone__sub { font-size: .85rem; margin-top: 4px; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; pointer-events: none; width: 100%; }

/* ---------- Form controls ---------- */
label.field { display: block; font-weight: 600; font-size: .9rem; margin: 16px 0 6px; }
input[type=text], input[type=number], select, textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; color: var(--text); background: var(--surface); transition: .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field-inline { display: flex; align-items: center; gap: 10px; }
.field-inline input[type=number] { width: 90px; }

/* segmented / radio group */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg label { padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--text-2); transition: .15s; }
.seg input { display: none; }
.seg input:checked + span, .seg label:has(input:checked) { background: var(--surface); color: var(--primary-d); box-shadow: var(--shadow-sm); }

/* mode buttons (spread) */
.mode-btn {
  padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface);
  cursor: pointer; font-weight: 600; font-size: .86rem; color: var(--text-2); transition: .15s;
}
.mode-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* range */
input[type=range] { width: 100%; accent-color: var(--primary); }

/* color presets (watermark) */
.color-presets { display: flex; gap: 8px; flex-wrap: wrap; }
.color-preset { width: 26px; height: 26px; border-radius: 7px; cursor: pointer; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.color-preset.active { border-color: var(--primary); }

/* ---------- Progress ---------- */
.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; margin-top: 14px; display: none; }
.progress-bar { height: 100%; width: 0%; background: var(--grad); border-radius: 999px; transition: width .2s; }

/* ---------- Status ---------- */
.status { margin-top: 12px; font-weight: 600; font-size: .9rem; min-height: 1.2em; color: var(--text-2); }
.status:empty { margin: 0; }

/* ---------- File list ---------- */
.file-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.file-item.dragging { opacity: .5; background: var(--primary-soft); }
.file-item.drag-over { border-color: var(--primary); }
.drag-handle { cursor: grab; color: var(--text-3); }
.file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pages, .file-size { font-size: .78rem; color: var(--text-3); }
.remove-file { border: none; background: transparent; color: var(--text-3); cursor: pointer; font-size: 1rem; padding: 4px 8px; border-radius: 8px; }
.remove-file:hover { background: #fee2e2; color: var(--danger); }
.empty-message, .empty-hint { color: var(--text-3); font-size: .88rem; text-align: center; padding: 18px; }

/* ---------- File info bar ---------- */
/* 注意：默认 display:flex，页面用内联 style="display:none" 初始隐藏，
   工具脚本执行 info.style.display='' 时回退到此可见状态 */
.file-info-bar { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 16px; background: var(--primary-soft); border: 1px solid #dfe2ff; border-radius: var(--radius-sm); }
.file-info-bar b { color: var(--primary-d); }

/* ---------- Preview grid ---------- */
/* 默认 display:block，需要初始隐藏的页面用内联 style="display:none" */
.preview-wrap { display: block; margin-top: 18px; }

/* 对开页拖拽提示 */
.floating-tooltip {
  position: fixed; pointer-events: none; z-index: 999; display: none;
  background: rgba(17,24,39,.85); color: #fff; padding: 4px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 12px; }
.preview-item {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface); cursor: grab; transition: .15s;
}
.preview-item.dragging { opacity: .45; border-style: dashed; border-color: var(--primary); }
.preview-item.drag-over-before { box-shadow: inset 3px 0 0 var(--primary); }
.preview-item .page-thumb { width: 100%; display: block; background: #fff; }
.preview-item .page-info { font-size: .76rem; padding: 5px 7px; color: var(--text-2); text-align: center; border-top: 1px solid var(--border); }
.checkbox-wrap { position: absolute; top: 6px; left: 6px; z-index: 2; }
.checkbox-wrap input { width: 16px; height: 16px; accent-color: var(--primary); }
.action-btns { position: absolute; top: 6px; right: 6px; display: none; gap: 4px; }
.preview-item:hover .action-btns { display: flex; }
.btn-icon-download { border: none; background: rgba(255,255,255,.92); border-radius: 7px; padding: 3px 7px; cursor: pointer; font-size: .8rem; box-shadow: var(--shadow-sm); }

/* ---------- Bookmark tree ---------- */
.bookmark-tree { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; margin-top: 12px; }
.bookmark-tree-item { font-size: .88rem; }
.bookmark-tree-label { display: flex; align-items: center; gap: 8px; padding: 5px 4px; }
.bookmark-tree-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-tree-page { color: var(--text-3); font-size: .78rem; }
.bookmark-tree-children { margin-left: 8px; border-left: 1px dashed var(--border-strong); padding-left: 8px; }

/* ---------- Spread preview ---------- */
.canvas-wrap { display: flex; justify-content: center; margin-top: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; overflow: auto; }
#split-book-preview-canvas { max-width: 100%; cursor: col-resize; border-radius: 6px; box-shadow: var(--shadow-sm); }
.kv { font-size: .88rem; color: var(--text-2); }
.kv b { color: var(--text); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 30px 0; background: var(--surface); }
.site-footer__inner { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: center; }
.site-footer__note { color: var(--text-3); font-size: .88rem; margin: 6px 0 0; }
.site-footer__privacy { color: var(--text-3); font-size: .85rem; max-width: 420px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .site-header__cta { display: none; }
  .tool-hero__head { flex-direction: column; align-items: flex-start; }
  .panel { padding: 18px; }
  .hero { padding: 44px 0 28px; }
}

/* ============================================================
   附加工具：文本转二维码 / 文本对比（沿用同一设计语言）
   ============================================================ */
.qr-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.qr-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; }
.qr-box--preview { background: var(--surface); align-items: center; justify-content: center; }
.qr-preview {
  width: 100%; flex: 1; min-height: 260px; aspect-ratio: 1 / 1; display: grid; place-items: center;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 18px; overflow: hidden;
}
.qr-preview canvas, .qr-preview img { max-width: 100%; max-height: 100%; }
.qr-hint { text-align: center; color: var(--text-3); margin-top: 12px; font-size: .9rem; }
.qr-charcount { font-size: .82rem; color: var(--text-3); margin-top: 6px; text-align: right; }
.qr-charcount.warn { color: var(--danger); font-weight: 600; }
.qr-charcount.caution { color: var(--warn); font-weight: 600; }

/* 文本对比 */
.cmp-toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.cmp-status { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--text-2); }
.cmp-status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px var(--success); }
.cmp-legend { display: flex; gap: 16px; margin-left: auto; flex-wrap: wrap; }
.cmp-legend span { display: inline-flex; align-items: center; gap: 7px; font-size: .85rem; color: var(--text-2); }
.cmp-swatch { width: 16px; height: 16px; border-radius: 5px; border: 1px solid var(--border-strong); }
.cmp-swatch.ins { background: #a8e6cf; }
.cmp-swatch.del { background: #ffaaa5; }

.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cmp-panel { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cmp-panel--in { border-color: #b9c2f0; }
.cmp-panel--out { border-color: #b6e3c6; }
.cmp-panel__head { padding: 12px 16px; font-weight: 700; color: #fff; display: flex; align-items: center; justify-content: space-between; font-size: .98rem; }
.cmp-panel--in .cmp-panel__head { background: var(--primary); }
.cmp-panel--out .cmp-panel__head { background: var(--success); }
.cmp-panel__head .cnt { font-weight: 500; background: rgba(255,255,255,.2); padding: 2px 10px; border-radius: 999px; font-size: .78rem; }
.cmp-editor { flex: 1; min-height: 240px; padding: 16px; line-height: 1.7; font-size: 15px; outline: none; overflow: auto; background: #fff; }
.cmp-editor[contenteditable="true"]:empty:before { content: attr(data-ph); color: var(--text-3); }
.cmp-editor--out { background: #f3fbf6; }
.hl-ins { background: #a8e6cf; border-radius: 3px; padding: 0 2px; }
.hl-del { background: #ffaaa5; text-decoration: line-through; border-radius: 3px; padding: 0 2px; color: #555; }

.cmp-stats { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 16px 0; }
.cmp-stat { display: inline-flex; align-items: center; gap: 7px; font-size: .88rem; background: #fff; border: 1px solid var(--border); padding: 6px 14px; border-radius: 999px; }
.cmp-stat b { color: var(--text); }
.cmp-stat.add b { color: var(--success); }
.cmp-stat.del b { color: var(--danger); }

#backToTop {
  position: fixed; right: 28px; bottom: 28px; width: 46px; height: 46px; border: none; border-radius: 50%;
  background: var(--grad); color: #fff; font-size: 20px; cursor: pointer; box-shadow: var(--shadow-lg);
  z-index: 1000; display: none; place-items: center; transition: .2s;
}
#backToTop.show { display: grid; }
#backToTop:hover { transform: translateY(-2px); filter: brightness(1.05); }

@media (max-width: 860px) {
  .qr-layout, .cmp-grid { grid-template-columns: 1fr; }
}
