* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: #1a1a1a; color: #dcdcdc;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}
header {
  background: #111; padding: 10px 16px; border-bottom: 1px solid #333;
  position: sticky; top: 0; z-index: 10;
}
header h1 {
  margin: 0 0 8px; font-size: 18px; color: #00c8ff;
}
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.btn {
  display: inline-block; padding: 6px 14px; background: #2c2c2c;
  border: 1px solid #444; color: #dcdcdc; cursor: pointer;
  border-radius: 4px; font-size: 13px; line-height: 1.4;
  transition: background 0.15s;
}
.btn:hover { background: #3a3a3a; }
.btn-go {
  background: #0a7d3a; border-color: #0d9c48; color: #fff; font-weight: bold;
}
.btn-go:hover { background: #0d9c48; }
.tb-label { color: #b0b0b0; font-size: 12px; margin-left: 8px; }

.thumb-picker { position: relative; display: inline-block; }
.picker-current {
  display: flex; align-items: center; gap: 8px;
  background: #2a2a2a; color: #dcdcdc; border: 1px solid #444;
  padding: 4px 8px; border-radius: 3px; font-size: 13px;
  cursor: pointer; min-width: 200px; min-height: 32px;
}
.picker-current:hover { background: #353535; }
.picker-current img {
  width: 36px; height: 36px; object-fit: contain;
  background: #141414; border-radius: 2px;
}
.picker-text { flex: 1; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.caret { color: #888; font-size: 10px; }
.picker-list {
  display: none; position: absolute; top: 100%; left: 0;
  background: #232323; border: 1px solid #444; border-radius: 3px;
  margin-top: 2px; z-index: 100; max-height: 360px; overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6); min-width: 280px;
}
.thumb-picker.open .picker-list { display: block; }
.picker-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; cursor: pointer; border-bottom: 1px solid #2a2a2a;
}
.picker-item:hover { background: #2e2e2e; }
.picker-item img {
  width: 60px; height: 60px; object-fit: contain;
  background: #141414; border-radius: 2px;
}
.picker-item .name { color: #dcdcdc; font-size: 13px; }
#status {
  color: #00c8ff; margin-left: 12px; font-weight: 500;
}

main {
  display: grid;
  grid-template-columns: 420px 1fr 360px;
  gap: 12px;
  padding: 12px 16px;
}
.col {
  background: #232323; padding: 10px;
  border: 1px solid #333; border-radius: 4px;
}
.col h2 {
  margin: 0 0 8px; font-size: 13px; color: #00c8ff;
  letter-spacing: 1px; text-transform: uppercase;
}
.canvas-wrap {
  background: #141414; border: 1px solid #444;
  display: inline-block; position: relative;
}
canvas {
  display: block; cursor: crosshair;
  image-rendering: pixelated;
}
#roi-info {
  margin-top: 6px; font-size: 12px; color: #aaa;
}

.field {
  margin-bottom: 10px;
}
.field label {
  display: block; font-size: 12px; color: #b0b0b0;
  margin-bottom: 3px;
}
.field select, .field input {
  width: 100%; background: #2a2a2a; color: #dcdcdc;
  border: 1px solid #444; padding: 5px 6px; border-radius: 3px;
  font-size: 12px;
}
.field input[type="range"] {
  padding: 0; height: 26px;
}
.field select:focus, .field input:focus {
  outline: 1px solid #00c8ff;
}

#v-score { color: #00c8ff; font-weight: bold; }
.hint { color: #777; font-size: 10px; font-weight: normal; margin-left: 4px; }

details { margin-top: 10px; font-size: 12px; }
details summary {
  cursor: pointer; padding: 4px 0; color: #00c8ff;
}
#adv-form {
  display: grid; grid-template-columns: 1fr 80px; gap: 3px 6px;
  margin-top: 4px;
}
#adv-form label { font-size: 11px; color: #999; }
#adv-form input {
  background: #2a2a2a; color: #dcdcdc; border: 1px solid #444;
  padding: 3px 5px; border-radius: 3px; font-size: 11px;
  width: 100%;
}

.kv {
  display: flex; justify-content: space-between;
  padding: 3px 0; font-size: 12px; border-bottom: 1px dotted #333;
}
.kv span:last-child { color: #80ff80; font-weight: bold; }

footer {
  padding: 10px 16px; border-top: 1px solid #333;
  min-height: 120px;
}
footer h2 {
  margin: 0 0 8px; font-size: 13px; color: #00c8ff;
  letter-spacing: 1px; text-transform: uppercase;
}
#legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 6px;
}
.legend-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; background: #232323;
  border-radius: 3px; font-size: 12px; font-family: monospace;
}
.legend-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}

#col-model, #col-scene { min-width: 0; }

/* Halcon-mode panel */
.halcon-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin-top: 6px;
  font-size: 12px;
}
.hc-row {
  display: flex; align-items: center; gap: 6px;
}
.hc-row.hc-num {
  flex-direction: column; align-items: flex-start;
}
.hc-row.hc-num label { font-size: 11px; color: #aaa; }
.hc-row.hc-num input { width: 100%; }

/* Edge preview panel */
.ep-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin-top: 6px;
  font-size: 12px;
}
.ep-row {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 11px; color: #aaa;
}
.ep-row input[type="range"] { width: 100%; }
.ep-row span { color: #fff; font-weight: bold; font-family: monospace; }
