/* ============ PDF 工具箱 样式 ============ */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e5e9f2;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --primary-soft: #eff4ff;
  --success: #16a34a;
  --success-soft: #ecfdf3;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 20px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff; box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}
.brand-text h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.brand-text p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.engine-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px;
}
.engine-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.engine-pill.ok .dot { background: var(--success); }
.engine-pill.warn .dot { background: var(--warn); }
.lang-toggle {
  margin-left: 10px; padding: 6px 14px; border: 1px solid #d1d5db; border-radius: 999px;
  background: #fff; color: #374151; font-size: 13px; font-weight: 600; cursor: pointer;
}
.lang-toggle:hover { border-color: #2563eb; color: #2563eb; }
[hidden] { display: none !important; }

/* ---------- 布局 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------- 工具卡片 ---------- */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 900px) { .tools-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .tools-grid { grid-template-columns: 1fr; } }

.tool-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  font-family: inherit;
}
.tool-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16, 24, 40, .1); border-color: #c7d5f5; }
.tool-card.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.tool-card .t-icon {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.tool-card.active .t-icon { background: var(--primary); color: #fff; }
.tool-card .t-name { font-size: 15px; font-weight: 600; color: var(--text); }
.tool-card .t-desc { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* ---------- 面板 ---------- */
.panel {
  margin-top: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  scroll-margin-top: 90px;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-head h2 { margin: 0 0 4px; font-size: 19px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 13px; }

.cap-badge {
  flex: none; font-size: 12px; padding: 5px 12px; border-radius: 999px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap;
}
.cap-badge.ok { background: var(--success-soft); color: var(--success); border-color: #bbe9cd; }
.cap-badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #fde7c2; }

/* ---------- 拖拽区 ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center;
  border: 2px dashed #c9d4e8; border-radius: 12px;
  background: #fafbfe; color: var(--muted);
  padding: 34px 20px; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
  outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.dropzone.dragover svg { color: var(--primary); }
.dropzone svg { color: #9db4e8; margin-bottom: 4px; }
.dz-main { font-size: 14px; color: var(--text); margin: 0; }
.dz-main .link { color: var(--primary); font-weight: 600; }
.dz-sub { font-size: 12px; margin: 0; color: var(--muted); }

/* ---------- 文件列表（图片排序） ---------- */
.img-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.img-list li {
  display: flex; align-items: center; gap: 12px;
  background: #fafbfe; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
.img-list .thumb {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none;
  background: #eef1f6;
}
.img-list .f-name { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.img-list .f-size { font-size: 12px; color: var(--muted); flex: none; }
.img-list .f-ops { display: flex; gap: 6px; flex: none; }
.img-list .f-ops button {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 14px;
  font-family: inherit;
}
.img-list .f-ops button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.img-list .f-ops button:disabled { opacity: .35; cursor: default; }
.img-list .f-ops .del:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- 表单 ---------- */
.md-area textarea {
  width: 100%; margin-top: 16px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-family: Consolas, Menlo, "Courier New", monospace;
  font-size: 13px; line-height: 1.6; color: var(--text); background: #fafbfe;
  resize: vertical; outline: none;
}
.md-area textarea:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

.url-row { display: flex; gap: 10px; }
.text-input {
  flex: 1; min-width: 0;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 14px; font-size: 14px; color: var(--text); background: #fafbfe;
  outline: none; font-family: inherit;
}
.text-input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

.opts {
  display: flex; flex-wrap: wrap; gap: 12px 18px;
  margin-top: 16px; align-items: center;
}
.opts label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.opts select, .level-row select {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 7px 10px; font-size: 13px; color: var(--text); outline: none; font-family: inherit;
  cursor: pointer;
}
.opts select:focus { border-color: var(--primary); }

.level-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.level-label { font-size: 13px; color: var(--muted); }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fafbfe; }
.segmented button {
  border: none; background: transparent; padding: 8px 20px; cursor: pointer;
  font-size: 13px; color: var(--muted); font-family: inherit;
}
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.active { background: var(--primary); color: #fff; }

/* ---------- 已选文件提示条 ---------- */
.file-chip {
  margin-top: 14px;
  display: flex; align-items: center; gap: 10px;
  background: var(--primary-soft); border: 1px solid #c7d5f5; border-radius: 10px;
  padding: 9px 14px; font-size: 13px; color: var(--text);
}
.file-chip button {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 2px 6px; border-radius: 6px; font-family: inherit;
}
.file-chip button:hover { color: var(--danger); }

/* ---------- PDF 高级工具表单 ---------- */
.opts label.wide { flex: 1 1 100%; }
.opts label.wide .text-input { flex: 1; }
.opts .text-input[type="password"] { letter-spacing: 2px; }
.check-row { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); flex: 1 1 100%; }
.check-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
.check-row .seg-label { flex: none; color: var(--muted); }
.img-list .f-idx { font-size: 12px; color: var(--muted); flex: none; min-width: 22px; }
.seg-label { font-size: 13px; color: var(--muted); }

/* ---------- 按钮 ---------- */
.actions { margin-top: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; padding: 11px 26px;
  font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
  font-family: inherit; transition: background .15s ease, transform .1s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-primary:disabled { background: #a8c0f2; cursor: not-allowed; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- 进度 ---------- */
.progress { margin-top: 18px; }
.progress .bar {
  height: 8px; border-radius: 999px; background: #e8edf6; overflow: hidden;
}
.progress .bar i {
  display: block; height: 100%; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  transition: width .3s ease;
}
.progress .msg { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.progress.error .msg { color: var(--danger); }

/* ---------- 结果 ---------- */
.result {
  margin-top: 18px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  background: var(--success-soft); border: 1px solid #bbe9cd;
  border-radius: 12px; padding: 16px 18px;
}
.result-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ok-icon {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--success); color: #fff; font-size: 17px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.r-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); word-break: break-all; }
.r-meta { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.result-actions { display: flex; gap: 10px; flex: none; }

/* ---------- 统计条 ---------- */
.stats-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 16px; margin-bottom: 16px;
}
.stats-bar b { color: var(--primary); font-weight: 700; }
.stats-bar .stat-sep { color: #cbd5e1; }
.stats-bar .stat-limit { color: var(--warn); font-weight: 600; }

/* ---------- 工具卡片使用次数角标 ---------- */
.tool-card { position: relative; }
.count-badge {
  position: absolute; top: 10px; right: 10px;
  font-size: 11px; line-height: 1; font-weight: 600;
  color: var(--primary); background: var(--primary-soft);
  border: 1px solid #c7d5f5; border-radius: 999px;
  padding: 4px 8px;
}
.tool-card.active .count-badge { background: #fff; }

/* ---------- 已保存的上传文件 ---------- */
.uploads-box {
  margin-top: 22px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.uploads-box summary {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 20px; cursor: pointer; user-select: none;
  font-size: 14px; font-weight: 600; color: var(--text);
  list-style: none;
}
.uploads-box summary::-webkit-details-marker { display: none; }
.uploads-box summary svg { margin-left: auto; transition: transform .2s ease; color: var(--muted); }
.uploads-box[open] summary svg { transform: rotate(180deg); }
.up-count {
  font-size: 11px; font-weight: 600; color: var(--primary);
  background: var(--primary-soft); border: 1px solid #c7d5f5;
  border-radius: 999px; padding: 3px 9px;
}
.uploads-list { border-top: 1px solid var(--line); max-height: 320px; overflow-y: auto; }
.up-empty { margin: 0; padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.up-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; font-size: 13px;
}
.up-row + .up-row { border-top: 1px solid #f1f4f9; }
.up-row .up-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.up-row .up-tag {
  flex: none; font-size: 11px; color: var(--primary);
  background: var(--primary-soft); border-radius: 6px; padding: 2px 8px;
}
.up-row .up-meta { flex: none; color: var(--muted); font-size: 12px; white-space: nowrap; }
.up-row .up-del {
  flex: none; border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 7px; width: 28px; height: 28px; cursor: pointer; font-size: 13px;
  font-family: inherit;
}
.up-row .up-del:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- 提示 ---------- */
.toast-wrap { position: fixed; top: 74px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #1f2937; color: #fff; font-size: 13px;
  padding: 11px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  animation: slideIn .25s ease;
  max-width: 360px;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--success); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.footnote { text-align: center; color: var(--muted); font-size: 12px; margin-top: 28px; }

@media (max-width: 640px) {
  .panel { padding: 18px; }
  .url-row { flex-direction: column; }
  .result { flex-direction: column; align-items: stretch; }
  .result-actions { justify-content: stretch; }
  .result-actions .btn { flex: 1; }
}
