/* ================= 基础 ================= */
* { box-sizing: border-box; }
:root {
  --bg: #f2f5fa;
  --panel: #ffffff;
  --line: #e4e9f2;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2f6fed;
  --primary-dark: #1f57c9;
  --primary-soft: #eaf1ff;
  --ok: #0f9d6e;
  --danger: #e5484d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.link { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }

/* ================= 顶栏 ================= */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  height: 60px; padding: 0 22px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(140deg, #3f7bf6, #1f57c9);
  color: #fff; box-shadow: 0 4px 10px rgba(47, 111, 237, .35);
}
.brand-name { font-size: 16px; letter-spacing: .3px; }
.brand-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .8px;
  padding: 2px 6px; border-radius: 5px;
  background: var(--primary-soft); color: var(--primary);
}
.tabs { display: flex; gap: 4px; padding: 4px; background: #eef1f7; border-radius: 11px; margin-left: 6px; }
.tab {
  border: 0; background: transparent; padding: 6px 16px; border-radius: 8px;
  color: #4b5563; cursor: pointer; font-weight: 500; transition: .16s;
}
.tab:hover { color: var(--text); }
.tab.active { background: #fff; color: var(--primary); font-weight: 650; box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #12b76a; box-shadow: 0 0 0 3px rgba(18, 183, 106, .16); }

/* ================= 按钮 ================= */
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 9px;
  padding: 8px 16px; cursor: pointer; font-weight: 550; transition: .16s;
}
.btn:hover { border-color: #cfd8e6; background: #fbfcfe; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }
.btn-danger { color: var(--danger); border-color: #f2d2d3; }
.btn-danger:hover { background: #fff5f5; border-color: #efb8ba; }

/* ================= 面板 ================= */
.main { max-width: 1180px; margin: 0 auto; padding: 26px 22px 80px; }
.panel { display: none; animation: fade .22s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panel-head { margin-bottom: 18px; }
.panel-head h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.2px; }
.panel-head p { margin: 0; color: var(--muted); }
.panel-head.row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

/* ================= 拖放区 ================= */
.dropzone {
  border: 1.5px dashed #c6d2e6; border-radius: var(--radius);
  background: #fbfcff; padding: 34px 20px; text-align: center;
  cursor: pointer; transition: .18s;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dz-icon { font-size: 26px; color: var(--primary); line-height: 1; margin-bottom: 8px; }
.dz-title { font-size: 15px; font-weight: 600; }
.dz-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* ================= 压缩级别 ================= */
.level-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0; }
.level { position: relative; cursor: pointer; }
.level input { position: absolute; opacity: 0; }
.level-body {
  border: 1.5px solid var(--line); background: #fff; border-radius: 12px;
  padding: 14px 16px; height: 100%; transition: .16s;
}
.level:hover .level-body { border-color: #c9d6ee; }
.level input:checked + .level-body { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.level-title { font-weight: 650; }
.level-desc { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.level-tag { margin-top: 8px; display: inline-block; font-size: 11.5px; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 2px 7px; border-radius: 6px; }

/* ================= 文件队列 ================= */
.queue { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.file-row {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 11px 14px;
  position: relative; overflow: hidden;
}
.pbar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: #eef1f7; }
.pbar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .15s linear; }
.pbar.ok i { background: var(--ok); }
.pbar.indet i { width: 34%; animation: sweep 1.1s ease-in-out infinite; }
@keyframes sweep { 0% { margin-left: -34%; } 100% { margin-left: 100%; } }
.file-ico {
  width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
  background: #fdecec; color: #d9484d; font-size: 10px; font-weight: 800; letter-spacing: .5px;
}
.file-main { min-width: 0; flex: 1; }
.file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { color: var(--muted); font-size: 12px; }
.file-status { font-size: 12.5px; font-weight: 600; }
.file-status.ok { color: var(--ok); }
.file-status.err { color: var(--danger); }
.file-status.run { color: var(--primary); }
.dl-link { color: var(--primary); font-weight: 650; text-decoration: none; white-space: nowrap; }

.actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; }

/* ================= 合并列表 ================= */
.merge-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.merge-item {
  display: flex; align-items: center; gap: 12px; background: #fff;
  border: 1px solid var(--line); border-radius: 11px; padding: 10px 14px; cursor: grab;
}
.merge-item.dragging { opacity: .4; }
.merge-item.drop-target { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.merge-idx {
  width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12px;
}
.merge-item .file-main { flex: 1; min-width: 0; }

/* ================= 拆分 ================= */
.split-file { margin: 16px 0; }
.seg { display: inline-flex; background: #eef1f7; border-radius: 10px; padding: 4px; gap: 3px; }
.seg-item { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; cursor: pointer; color: #4b5563; }
.seg-item.active { background: #fff; color: var(--primary); font-weight: 650; box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.split-options { margin-top: 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.field { margin-top: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.field input {
  width: 100%; max-width: 340px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 9px; background: #fbfcfe; outline: none;
}
.field input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
.hint { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }

/* ================= 编辑器 ================= */
.editor { margin-top: 18px; }
.editor-top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px;
}
.tools { display: flex; gap: 3px; padding: 3px; background: #f1f4f9; border-radius: 9px; flex-wrap: wrap; }
.tool {
  border: 0; background: transparent; padding: 6px 11px; border-radius: 7px;
  cursor: pointer; color: #4b5563; font-size: 13px;
}
.tool:hover { background: #fff; }
.tool.active { background: #fff; color: var(--primary); font-weight: 650; box-shadow: 0 1px 3px rgba(16,24,40,.1); }
.zoom { display: flex; align-items: center; gap: 6px; margin-left: auto; color: var(--muted); font-size: 12.5px; }
.editor-body {
  display: grid; grid-template-columns: 168px minmax(0, 1fr) 274px; gap: 12px;
  margin-top: 12px; height: calc(100vh - 190px); min-height: 460px;
}
.thumbs, .inspector { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.thumbs { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.thumb {
  position: relative; border: 1.5px solid transparent; border-radius: 8px;
  background: #f6f8fc; cursor: pointer; padding: 4px; transition: .15s;
}
.thumb.active { border-color: var(--primary); background: var(--primary-soft); }
.thumb.dragging { opacity: .4; }
.thumb-img { width: 100%; display: block; border-radius: 4px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.thumb-num {
  position: absolute; left: 8px; bottom: 8px; background: rgba(17, 24, 39, .72); color: #fff;
  font-size: 11px; padding: 1px 6px; border-radius: 5px;
}
.thumb-tools {
  position: absolute; top: 6px; right: 6px; display: none; gap: 3px;
}
.thumb:hover .thumb-tools { display: flex; }
.thumb-tools button {
  width: 22px; height: 22px; border: 0; border-radius: 5px; cursor: pointer;
  background: rgba(17, 24, 39, .72); color: #fff; font-size: 12px; line-height: 1;
  display: grid; place-items: center;
}
.thumb-tools button:hover { background: var(--primary); }
.stage-wrap {
  background: #e9edf5; border: 1px solid var(--line); border-radius: 12px;
  overflow: auto; padding: 26px; display: flex; justify-content: center; align-items: flex-start;
}
.stage { position: relative; background: #fff; box-shadow: 0 6px 26px rgba(16, 24, 40, .16); flex: none; }
.stage .page-img { position: absolute; left: 50%; top: 50%; transform-origin: center center; user-select: none; pointer-events: none; }
.stage .overlay { position: absolute; inset: 0; }
.ov-el { position: absolute; cursor: move; }
.ov-el.sel { outline: 1.5px solid var(--primary); outline-offset: 1px; }
.ov-text { white-space: pre-wrap; overflow: hidden; cursor: move; }
.ov-text[contenteditable="true"] { cursor: text; outline: 1.5px solid var(--primary); background: rgba(47,111,237,.04); }
.ov-text:empty:before { content: "双击输入文字"; color: #9aa3b2; }
.ov-img img, .ov-rect, .ov-highlight, .ov-redact { width: 100%; height: 100%; display: block; }
.ov-redact { background: #000; }
.ov-highlight { background: rgba(255, 221, 0, .45); }
.ov-rect { background: #fff; }
.ov-wm { color: rgba(229, 72, 77, .28); font-weight: 800; display: grid; place-items: center; pointer-events: none; }
.handle {
  position: absolute; width: 10px; height: 10px; background: #fff; border: 1.5px solid var(--primary);
  border-radius: 3px; z-index: 5;
}
.handle.br { right: -5px; bottom: -5px; cursor: nwse-resize; }
.handle.bl { left: -5px; bottom: -5px; cursor: nesw-resize; }
.handle.tr { right: -5px; top: -5px; cursor: nesw-resize; }
.handle.tl { left: -5px; top: -5px; cursor: nwse-resize; }
.handle.mr { right: -5px; top: 50%; margin-top: -5px; cursor: ew-resize; }
.handle.mb { bottom: -5px; left: 50%; margin-left: -5px; cursor: ns-resize; }

/* ================= 属性面板 ================= */
.inspector { padding: 14px; font-size: 13px; }
.insp-empty { color: var(--muted); text-align: center; padding: 22px 8px; font-size: 12.5px; }
.insp-title { font-weight: 700; font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: #98a1b0; margin-bottom: 10px; }
.insp-line { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; color: var(--muted); }
.insp-line b { color: var(--text); font-weight: 600; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-doc { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.insp-tip { color: var(--muted); font-size: 12px; margin-top: 8px; line-height: 1.6; }
.insp-group { margin-bottom: 14px; }
.insp-group > label { display: block; font-size: 12px; font-weight: 600; color: #4b5563; margin-bottom: 5px; }
.insp-group input[type=text], .insp-group input[type=number], .insp-group select {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe; outline: none;
}
.insp-group input:focus, .insp-group select:focus { border-color: var(--primary); background: #fff; }
.insp-row { display: flex; gap: 8px; }
.insp-row > * { flex: 1; min-width: 0; }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type=color] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.btn-mini { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

/* ================= 文件库 ================= */
.lib { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.lib-row {
  display: flex; align-items: center; gap: 14px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px;
}
.lib-row:hover { border-color: #d3ddec; }
.lib-meta { flex: 1; min-width: 0; }
.lib-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.lib-actions { display: flex; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 50px 0; }
.lib-summary { margin-top: 9px; color: var(--muted); font-size: 12.5px; }

/* ================= 处理记录 ================= */
.hist { display: flex; flex-direction: column; gap: 10px; }
.hist-row {
  display: flex; align-items: center; gap: 14px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px;
}
.hist-row:hover { border-color: #d3ddec; }
.hist-badge {
  flex: none; font-size: 11.5px; font-weight: 700; letter-spacing: .3px;
  padding: 4px 9px; border-radius: 7px; background: #eef2f8; color: #5b6b82;
}
.hist-badge.compress { background: #e7f7ef; color: #0f9d6e; }
.hist-badge.merge { background: #eef2ff; color: #4b5fd6; }
.hist-badge.split { background: #fff4e5; color: #b26a00; }
.hist-badge.edit { background: #fdeef6; color: #b3327a; }
.hist-main { flex: 1; min-width: 0; }
.hist-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.hist-sub b { color: var(--ok); font-weight: 700; }

/* ================= Toast ================= */
.toast-wrap { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #111827; color: #fff; padding: 9px 16px; border-radius: 9px;
  font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,.22); animation: up .2s ease;
  max-width: 80vw;
}
.toast.ok { background: #067a55; }
.toast.err { background: #b42318; }
@keyframes up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ================= 登录页 ================= */
.login-body {
  display: grid; place-items: center; min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, #dfe9ff 0%, #f2f5fa 55%);
}
.login-card {
  width: 348px; background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 34px 30px 24px; box-shadow: 0 20px 60px rgba(16, 24, 40, .12); text-align: center;
}
.login-logo {
  width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(140deg, #3f7bf6, #1f57c9); color: #fff; box-shadow: 0 10px 22px rgba(47,111,237,.35);
}
.login-card h1 { margin: 0 0 4px; font-size: 21px; }
.login-sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: #fbfcfe; outline: none; margin-bottom: 12px; text-align: center; letter-spacing: 2px;
}
.login-card input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
.login-err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 8px; }
.login-foot { color: #a4adbb; font-size: 11.5px; margin: 14px 0 0; }

/* ================= 响应式 ================= */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .main { padding: 16px 14px 60px; }
  .level-row { grid-template-columns: 1fr; }
  .editor-body { grid-template-columns: 1fr; height: auto; }
  .thumbs { flex-direction: row; overflow-x: auto; }
  .thumb { width: 100px; flex: none; }
  .inspector { order: 3; }
  .stage-wrap { min-height: 460px; }
}
