:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1c2024;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #c2410c;
  --accent-soft: #fff1e7;
  --ok: #15803d;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

header {
  height: 58px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand strong { font-size: 17px; letter-spacing: .02em; }
.brand span { color: var(--muted); font-size: 12px; }
.badge {
  border: 1px solid #f3c9ad;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.layout { display: flex; height: calc(100% - 58px); }
.sidebar {
  width: 348px;
  flex: 0 0 348px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  padding: 18px 18px 28px;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin: 22px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
h2:first-child { margin-top: 0; }

.drop {
  border: 1.5px dashed #cfd4da;
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  background: #fafbfc;
  cursor: pointer;
  transition: .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { display: block; font-size: 13px; }
.drop small { color: var(--muted); }
.drop input { display: none; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; }
.row label { color: #374151; font-size: 13px; }
.row .value { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.field { margin: 10px 0; }
.field > label { display: flex; justify-content: space-between; font-size: 13px; color: #374151; margin-bottom: 5px; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field input[type="number"], .field select, .field input[type="text"] {
  width: 100%; padding: 7px 9px; border: 1px solid #d8dce1; border-radius: 7px;
  background: #fff; color: var(--ink); font: inherit; font-size: 13px;
}
.field input:focus, .field select:focus { outline: 2px solid #fbd9c4; border-color: var(--accent); }
.field input[type="range"] + input[type="number"] { margin-top: 7px; }
.hint { color: var(--muted); font-size: 11px; margin: 4px 0 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #374151; cursor: pointer; }
.check input { accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

button {
  font: inherit; font-size: 13px; font-weight: 600;
  border: 1px solid #d8dce1; border-radius: 8px;
  background: #fff; color: var(--ink); padding: 9px 12px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: #b9bfc7; background: #f9fafb; }
button.active { border-color: #f3c9ad; background: var(--accent-soft); color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: #a73509; border-color: #a73509; }
.actions { display: flex; gap: 8px; margin-top: 18px; }
.actions button { flex: 1; }
.wide { width: 100%; }

/* ---------- preprocessing: one-click + box select ---------- */
.pp-actions { margin-top: 8px; }
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(15, 23, 42, .5);
}
.modal[hidden] { display: none; }
.pp-card.pp-simple {
  width: min(960px, 100%); height: min(680px, 100%);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border-radius: 12px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}
.pp-head {
  flex: 0 0 52px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line);
}
.pp-head button { padding: 5px 10px; font-size: 12px; }
.pp-heading { display: flex; align-items: baseline; gap: 10px; }
.pp-heading strong { font-size: 15px; }
.pp-sub { color: var(--muted); font-size: 12px; }
.pp-view { flex: 1; min-height: 0; position: relative; background: #eceef1; }
#ppCanvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.pp-tip {
  position: absolute; left: 12px; bottom: 12px; pointer-events: none;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 9px; font-size: 11px; color: #4b5563;
}
.pp-foot {
  flex: 0 0 54px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-top: 1px solid var(--line);
}
.pp-foot .spacer { flex: 1; }
#ppStatus { font-size: 12px; }

details { margin-top: 18px; font-size: 12px; color: var(--muted); }
details summary { cursor: pointer; color: #374151; font-weight: 600; }
details p { margin: 8px 0 0; }

.viewbar {
  height: 46px; flex: 0 0 46px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.viewbar .spacer { flex: 1; }
.viewbar button { padding: 5px 10px; font-size: 12px; }
.stat { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.stage { flex: 1; position: relative; overflow: hidden; background: #eceef1; }
#preview { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#preview.dragging { cursor: grabbing; }
.empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #9aa1a9; font-size: 14px; pointer-events: none;
}

.footer {
  flex: 0 0 auto; border-top: 1px solid var(--line); background: var(--panel);
  padding: 12px 16px; display: flex; align-items: center; gap: 14px;
}
.progress { flex: 1; }
.progress .track { height: 5px; background: #e7eaee; border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: var(--accent); transition: width .12s; }
.progress .label { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
#downloadBtn { padding: 9px 18px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; height: auto; }
  .sidebar { width: 100%; flex: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .main { min-height: 520px; }
  body { height: auto; }
}
