/* ==========================================================
   PDF 拆分工具 · 网页版样式
   浅色主题，与 Python 版统一的视觉语言
   ========================================================== */

:root {
  --bg:        #F4F6FA;
  --card:      #FFFFFF;
  --border:    #E2E6EF;
  --border-2:  #D5DBE8;
  --text:      #1D2433;
  --muted:     #6B7690;
  --muted-2:   #8B95AC;
  --accent:    #3A6FF7;
  --accent-d:  #2B58CC;
  --accent-s:  #EAF0FF;
  --ok:        #12A150;
  --ok-s:      #E7F7EE;
  --warn:      #D97706;
  --warn-s:    #FEF3E2;
  --err:       #DC2626;
  --err-s:     #FDECEC;
  --radius:    12px;
  --radius-s:  8px;
  --shadow:    0 1px 2px rgba(20, 30, 60, .05), 0 8px 24px rgba(20, 30, 60, .06);
  --shadow-s:  0 1px 2px rgba(20, 30, 60, .06);
  --mono:      "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Hiragino Sans GB",
               -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------- 布局骨架 */

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 24px 0;
}

.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 13px; }

.logo {
  width: 44px; height: 44px;
  flex: 0 0 44px;
  display: grid; place-items: center;
  background: var(--accent-s);
  color: var(--accent);
  border-radius: 11px;
}

.head h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .2px;
}

.head .sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.head-badge {
  font-size: 12px;
  color: var(--ok);
  background: var(--ok-s);
  border: 1px solid #C7EBD6;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

/* 主区：左内容 / 右参数 */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
  padding-bottom: 18px;
}

.col-main, .col-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ---------------------------------------------- 拖放区 */

.drop {
  position: relative;
  border: 2px dashed var(--border-2);
  border-radius: var(--radius);
  background: #FBFCFE;
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .12s;
  color: var(--muted);
  outline: none;
}

.drop:hover { border-color: #B9C6E4; background: #F8FAFF; }
.drop:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-s); }

.drop.active {
  border-color: var(--accent);
  background: var(--accent-s);
  color: var(--accent);
  transform: scale(1.005);
}

.drop.has-files {
  border-color: var(--accent);
  border-style: dashed;
  color: var(--accent);
}

.drop-icon { color: currentColor; opacity: .85; }

.drop-title {
  margin-top: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.drop.active .drop-title,
.drop.has-files .drop-title { color: var(--accent); }

.drop-hint { margin-top: 5px; font-size: 12.5px; color: var(--muted); }

.drop-cta {
  margin-top: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}

/* ---------------------------------------------- 面板 */

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-s);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #FCFDFF;
}

.panel-title {
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-tools { display: flex; gap: 6px; }

.pill {
  display: inline-block;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-s);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
}

.panel-body { padding: 15px 16px; }

/* ---------------------------------------------- 文件列表 */

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  outline: none;
}

.file-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid #F0F3F8;
  cursor: pointer;
  transition: background .12s;
}

.file-list li:last-child { border-bottom: none; }
.file-list li:hover { background: #FAFBFE; }
.file-list li.sel { background: var(--accent-s); }

.file-list .idx {
  flex: 0 0 26px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted-2);
  text-align: right;
}

.file-list .nm {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list .meta {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--muted-2);
  font-family: var(--mono);
}

.file-list .tag {
  flex: 0 0 auto;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.tag.done { background: var(--ok-s); color: var(--ok); }
.tag.fail { background: var(--err-s); color: var(--err); }
.tag.busy { background: var(--accent-s); color: var(--accent); }

.empty {
  padding: 22px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted-2);
}

/* ---------------------------------------------- 日志 */

.log {
  height: 190px;
  overflow-y: auto;
  background: #0F1626;
  padding: 11px 13px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  color: #C7D2E4;
  white-space: pre-wrap;
  word-break: break-all;
}

.log .l-dim  { color: #7C8AA5; }
.log .l-ok   { color: #4ADE80; }
.log .l-err  { color: #F87171; }
.log .l-warn { color: #FBBF24; }

/* ---------------------------------------------- 表单 */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 6px;
}

.field label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.field-val {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.unit { font-weight: 400; color: var(--muted-2); font-size: 11.5px; }

.field-help {
  font-size: 11.5px;
  color: var(--muted-2);
  margin-top: 5px;
  line-height: 1.55;
}
.mt8 { margin-top: 8px; }

input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-s);
  background: #FFF;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}

input[type="number"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-s);
}

/* 滑块 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: #E6EBF5;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid #FFF;
  box-shadow: 0 1px 4px rgba(58, 111, 247, .45);
  cursor: pointer;
  transition: transform .12s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }

input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid #FFF;
  box-shadow: 0 1px 4px rgba(58, 111, 247, .45);
  cursor: pointer;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 12.5px;
  cursor: pointer;
  margin-bottom: 0;
}

.check input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

/* ---------------------------------------------- 按钮 */

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  padding: 8px 15px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}

.btn:disabled { cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #FFF;
  padding: 10px 26px;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(58, 111, 247, .28);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-d); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled {
  background: #B8C4E2;
  box-shadow: none;
}

.btn-ghost {
  background: #FFF;
  border-color: var(--border-2);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: var(--accent-s); border-color: #C3D2F5; color: var(--accent-d); }
.btn-ghost:disabled { color: #A6AEC0; background: #F7F8FB; }

.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ---------------------------------------------- 图示 */

.diagram {
  background: #F8FAFF;
  border: 1px solid #E8EEFC;
  border-radius: var(--radius-s);
  padding: 13px;
  text-align: center;
  margin-bottom: 12px;
}

.dg-row { display: flex; justify-content: center; gap: 6px; }

.dg-src {
  display: flex;
  width: 100%;
  height: 40px;
  border: 2px solid #B9C6E4;
  border-radius: 5px;
  overflow: hidden;
  background: #FFF;
}

.dg-half {
  flex: 1;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--muted);
}
.dg-half:first-child { border-right: 1px dashed #B9C6E4; }

.dg-arrow {
  font-size: 11px;
  color: var(--muted-2);
  padding: 8px 0;
}

.dg-a4 {
  width: 33px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--accent);
  border-radius: 3px;
  background: var(--accent-s);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

.rules {
  margin: 0;
  padding-left: 17px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.85;
}
.rules b { color: var(--text); }

/* ---------------------------------------------- 引擎状态 */

.engine-list { display: flex; flex-direction: column; gap: 7px; }

.engine {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
  background: var(--muted-2);
}
.dot.ok   { background: var(--ok); }
.dot.load { background: var(--warn); animation: pulse 1.1s ease-in-out infinite; }
.dot.err  { background: var(--err); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .3; }
}

.engine .en-name { flex: 1; font-weight: 600; }
.engine .en-state { color: var(--muted-2); font-size: 11.5px; }
.engine .en-state.ok { color: var(--ok); }
.engine .en-state.err { color: var(--err); }

/* ---------------------------------------------- 底栏 */

.foot {
  position: sticky;
  bottom: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 16px rgba(20, 30, 60, .05);
  margin: 0 -24px;
  padding: 0 24px;
}

.progress {
  height: 3px;
  background: #EDF1F8;
  border-radius: 2px;
  overflow: hidden;
  margin: 0 -24px 0;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #6E9BFF);
  transition: width .22s ease;
}

.foot-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  flex-wrap: wrap;
}

.status { font-size: 12.5px; color: var(--muted); }
.status.busy { color: var(--accent); font-weight: 600; }
.status.done { color: var(--ok); font-weight: 600; }
.status.err  { color: var(--err); font-weight: 600; }

.foot-actions { display: flex; gap: 9px; }

/* ---------------------------------------------- 滚动条 */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #CFD7E6;
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #B4BFD4; background-clip: content-box; }

.log::-webkit-scrollbar-thumb { background: #33415C; background-clip: content-box; }
.log::-webkit-scrollbar-thumb:hover { background: #44536F; background-clip: content-box; }

/* ---------------------------------------------- 响应式 */

@media (max-width: 1040px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .col-side { order: -1; }
  .app { padding: 18px 16px 0; }
  .foot { margin: 0 -16px; padding: 0 16px; }
  .progress { margin: 0 -16px; }
}

@media (max-width: 560px) {
  .head h1 { font-size: 17px; }
  .head-badge { display: none; }
  .drop { padding: 26px 14px; }
  .panel-tools { flex-wrap: wrap; }
  .foot-inner { flex-direction: column; align-items: stretch; }
  .foot-actions { justify-content: stretch; }
  .foot-actions .btn { flex: 1; }
}
