:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e7eaf0;
  --line-2: #dfe3ec;
  --text: #171a21;
  --text-2: #5c6675;
  --text-3: #939cab;
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: #eef1ff;
  --a-color: #4f46e5;
  --b-color: #0d9488;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 25, 40, .04), 0 8px 24px rgba(20, 25, 40, .06);
  --shadow-sm: 0 1px 2px rgba(20, 25, 40, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.app { max-width: 1440px; margin: 0 auto; padding: 22px 24px 40px; }
.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #6366f1, #4f46e5 45%, #7c3aed);
  box-shadow: 0 6px 16px rgba(79, 70, 229, .28);
}
.brand-text h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.brand-text p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-3); }
.top-actions { display: flex; gap: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 8px 14px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: .16s; font-family: var(--font);
}
.btn:hover { border-color: #c9cfe0; background: var(--surface-2); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.ghost { color: var(--text-2); }
.btn.primary {
  background: linear-gradient(135deg, #5b54ea, #4f46e5); border-color: #4f46e5; color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, .26);
}
.btn.primary:hover { background: linear-gradient(135deg, #6a63f0, #5b54ea); }
.btn.big { padding: 11px 30px; font-size: 14.5px; border-radius: 11px; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
  margin-bottom: 18px;
}
.card-title { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.card-title h2 { margin: 0; font-size: 15px; font-weight: 650; }
.card-title .sub { font-size: 12.5px; color: var(--text-3); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }

/* ---------- 上传槽 ---------- */
.slots { display: grid; grid-template-columns: 1fr 56px 1fr; gap: 12px; align-items: stretch; }
.slot-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.tag {
  font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  letter-spacing: .3px;
}
.tag.ta { background: var(--primary-soft); color: var(--a-color); }
.tag.tb { background: #e6f7f4; color: var(--b-color); }
.slot-hint { font-size: 12px; color: var(--text-3); }

.drop {
  border: 1.5px dashed var(--line-2); border-radius: 12px; background: var(--surface-2);
  min-height: 150px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: .18s; padding: 14px; position: relative;
}
.drop:hover { border-color: var(--primary-2); background: #f6f7ff; }
.drop.drag { border-color: var(--primary); background: #eef1ff; }
.drop-inner { text-align: center; color: var(--text-3); pointer-events: none; }
.drop-inner svg { color: #b6bdcd; margin-bottom: 6px; }
.drop-inner p { margin: 6px 0 2px; font-size: 13.5px; color: var(--text-2); font-weight: 500; }
.drop-inner span { font-size: 12px; color: var(--text-3); }

.file-info { display: flex; align-items: center; gap: 12px; width: 100%; }
.ficon {
  width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .5px; flex: none;
}
.ficon.pdf { background: linear-gradient(135deg, #f87171, #dc2626); }
.ficon.txt { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.fmeta { flex: 1; min-width: 0; }
.fmeta .fname { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmeta .fsub { font-size: 12px; color: var(--text-3); }
.rm {
  border: none; background: transparent; color: var(--text-3); font-size: 20px;
  cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.rm:hover { background: #fee2e2; color: var(--danger); }

.swap { display: grid; place-items: center; color: #c3c9d8; }

/* ---------- 参数 ---------- */
.options {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr 1fr auto; gap: 22px; align-items: start;
}
.opt.range label { font-size: 13px; color: var(--text-2); display: block; margin-bottom: 6px; }
.opt.range label b { color: var(--primary); font-size: 14px; }
input[type=range] { width: 100%; max-width: 360px; accent-color: var(--primary); }
.opt-tip { display: block; font-size: 12px; color: var(--text-3); margin-top: 4px; }
.checks { display: flex; flex-direction: column; gap: 7px; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.chk input { accent-color: var(--primary); width: 15px; height: 15px; }
.chk.sm { font-size: 12.5px; }

.run-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.status { font-size: 13px; color: var(--text-2); }
.status.err { color: var(--danger); }
.spin {
  width: 13px; height: 13px; border: 2px solid #c7d2fe; border-top-color: var(--primary);
  border-radius: 50%; display: inline-block; margin-right: 7px; animation: sp .7s linear infinite;
  vertical-align: -2px;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- 结果概览 ---------- */
.summary { display: flex; gap: 26px; align-items: center; }
.gauge-wrap { position: relative; width: 150px; height: 150px; flex: none; }
.gauge { width: 150px; height: 150px; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 11; stroke-linecap: round; }
.g-bg { stroke: #eef0f5; }
.g-fg { stroke: var(--primary); transition: stroke-dashoffset .8s cubic-bezier(.3,1,.4,1), stroke .4s; }
.gauge-center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.g-num { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.g-label { font-size: 12px; color: var(--text-3); margin-top: -2px; }

.summary-body { flex: 1; min-width: 0; }
.verdict {
  font-size: 15px; font-weight: 650; margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.verdict .pill { font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
.pill.low { background: #dcfce7; color: #15803d; }
.pill.mid { background: #fef3c7; color: #b45309; }
.pill.high { background: #fee2e2; color: #b91c1c; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.m-head { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.m-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-bar { height: 7px; background: #eef0f5; border-radius: 6px; overflow: hidden; }
.m-bar i { display: block; height: 100%; background: linear-gradient(90deg, #818cf8, #4f46e5); border-radius: 6px; transition: width .7s; }
.m-bar i.b { background: linear-gradient(90deg, #5eead4, #0d9488); }
.m-val { display: flex; align-items: baseline; gap: 9px; margin-top: 5px; }
.m-val b { font-size: 16px; }
.m-val span { font-size: 12px; color: var(--text-3); }

.quick-stats { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.qs {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 14px; min-width: 96px;
}
.qs b { display: block; font-size: 15px; }
.qs span { font-size: 11.5px; color: var(--text-3); }

/* ---------- 阅读器 ---------- */
.viewer { padding-bottom: 14px; }
.viewer-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 14px;
}
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.tab {
  border: none; background: transparent; padding: 6px 16px; border-radius: 8px;
  font-size: 13px; color: var(--text-2); cursor: pointer; font-family: var(--font);
}
.tab.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.tools { display: flex; align-items: center; gap: 14px; }
.font-ctl { display: flex; gap: 4px; }
.font-ctl button {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px;
  padding: 4px 9px; font-size: 12px; cursor: pointer; color: var(--text-2);
}
.font-ctl button:hover { background: var(--surface-2); }

.panes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pane { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.pane-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 13px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.pane-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.pane-rate { font-size: 12px; color: var(--text-3); }
.pane-rate b { color: var(--danger); font-size: 13px; }

.minimap { height: 9px; background: #f1f3f8; position: relative; cursor: pointer; border-bottom: 1px solid var(--line); }
.mm-view { position: absolute; top: 0; height: 100%; background: rgba(79,70,229,.16); border-left: 1px solid rgba(79,70,229,.5); border-right: 1px solid rgba(79,70,229,.5); pointer-events: none; }

.pane-body {
  position: relative;
  height: clamp(380px, 56vh, 800px); overflow-y: auto; padding: 14px 16px; font-size: 14px; line-height: 1.95;
  color: #262b34; scroll-behavior: auto;
}
.pane-body p { margin: 0 0 .85em; text-align: justify; word-break: break-word; }
.pane-body p.empty { height: .5em; }
.pane-body.fold p:not(.has-dup):not(.has-fuzzy) { display: none; }

mark.dup {
  background: #fff3c4; border-radius: 3px; padding: 1px 0; cursor: pointer;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.08); transition: background .12s, box-shadow .12s;
}
mark.dup:hover, mark.dup.hot {
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.22), 0 0 0 2px rgba(79,70,229,.35);
  border-radius: 4px;
}
mark.dup.flash { animation: flash 1.1s ease; }
@keyframes flash { 0%,100% { box-shadow: inset 0 -2px 0 rgba(0,0,0,.08); } 30% { box-shadow: 0 0 0 3px rgba(79,70,229,.5); } }

mark.fuzzy {
  background: #fff8e1; border-radius: 3px; cursor: pointer; padding: 1px 0;
  box-shadow: inset 0 -2px 0 #f0b429;
}
mark.fuzzy:hover, mark.fuzzy.hot {
  box-shadow: 0 0 0 2px rgba(245, 158, 11, .5);
}
.lg.lf { background: #fff8e1; box-shadow: inset 0 -2px 0 #f0b429; }

.subtabs { display: inline-flex; gap: 6px; }
.stab {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px;
  padding: 4px 12px; font-size: 12.5px; cursor: pointer; color: var(--text-2); font-family: var(--font);
}
.stab.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.stab b { font-weight: 700; }
.stab:disabled { opacity: .5; cursor: not-allowed; }

.c0 { background: #ffe2e2 !important; }
.c1 { background: #ffe9cc !important; }
.c2 { background: #fff6c9 !important; }
.c3 { background: #e3f8d6 !important; }
.c4 { background: #ccf5e7 !important; }
.c5 { background: #d3ecff !important; }
.c6 { background: #e2dcff !important; }
.c7 { background: #ffdcf1 !important; }

/* ---------- 片段清单 ---------- */
.listview { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.list-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--text-2);
}
.list-head input {
  border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 11px; font-size: 13px;
  width: 220px; font-family: var(--font);
}
.list-body { max-height: 560px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3);
  padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fbfcfe;
  position: sticky; top: 0;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid #f0f2f6; font-size: 12.8px; vertical-align: top; }
tbody tr:hover { background: #f9fafd; }
.td-idx { color: var(--text-3); font-variant-numeric: tabular-nums; }
.td-len { font-weight: 650; color: var(--text-2); font-variant-numeric: tabular-nums; }
.snip { color: #2b313c; line-height: 1.7; }
.snip mark { background: #fff6c9; border-radius: 2px; }
.jump { border: 1px solid var(--line-2); background: var(--surface); border-radius: 7px; padding: 3px 9px; font-size: 12px; cursor: pointer; color: var(--primary); white-space: nowrap; }
.jump:hover { background: var(--primary-soft); }
.chip { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--primary-soft); color: var(--primary); font-weight: 600; margin-right: 6px; }
.chip.b { background: #e6f7f4; color: var(--b-color); }

/* ---------- 图例 ---------- */
.legend {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3);
  padding: 2px 4px 0; flex-wrap: wrap;
}
.lg { width: 16px; height: 12px; border-radius: 3px; display: inline-block; }
.lg-tip { margin-left: 6px; }

.foot { text-align: center; font-size: 12px; color: var(--text-3); margin-top: 26px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: #171a21; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,.22);
  animation: up .2s ease;
}
@keyframes up { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 1080px) {
  .slots { grid-template-columns: 1fr; }
  .swap { transform: rotate(90deg); height: 24px; }
  .panes { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; gap: 14px; }
  .metrics { grid-template-columns: 1fr; }
  .summary { flex-direction: column; align-items: stretch; }
  .gauge-wrap { margin: 0 auto; }
}
