/* 零件 catalog 以图找图 - 样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  background: #f4f6f8;
  color: #1a1a1a;
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, #1f4e79 0%, #2e75b6 100%);
  color: white;
  padding: 20px 32px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

header h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 12px;
}

nav {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.tab-btn:hover { background: rgba(255,255,255,0.25); }
.tab-btn.active {
  background: white;
  color: #1f4e79;
  font-weight: 600;
}

.tab {
  display: none;
  padding: 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
}

.tab.active { display: block; }

.panel {
  background: white;
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.panel h2 {
  font-size: 16px;
  margin-bottom: 8px;
  color: #2e75b6;
}

.stats {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.stat { display: flex; flex-direction: column; }
.stat label {
  font-size: 12px;
  color: #888;
  margin-bottom: 2px;
}
.stat b {
  font-size: 18px;
  color: #1f4e79;
}

.btn {
  background: #2e75b6;
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}
.btn:hover { background: #1f4e79; }
.btn.primary { background: #4caf50; }
.btn.primary:hover { background: #388e3c; }
.btn.danger { background: #e74c3c; }
.btn.danger:hover { background: #c0392b; }
.btn.small {
  padding: 3px 10px;
  font-size: 12px;
  margin-left: 8px;
  vertical-align: middle;
}

.upload-zone {
  border: 2px dashed #c8d4e0;
  border-radius: 10px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafbfc;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: #2e75b6;
  background: #e8f1fa;
}
.upload-zone p {
  color: #6c7a89;
  font-size: 15px;
}

.sticky-panel {
  position: sticky;
  top: 0;
  z-index: 100;
  max-height: 78vh;
  overflow-y: auto;
  padding: 14px 16px;
  margin-top: 0;
}
.sticky-panel h2 { margin-bottom: 10px; }
.sticky-panel.compact .upload-row { display: none; }
.sticky-panel.compact .compact-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.sticky-panel .compact-bar { display: none; }

.upload-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}

.upload-mini {
  border: 2px dashed #c8d4e0;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafbfc;
  min-height: 80px;
  position: relative;
  overflow: hidden;
}
.upload-mini:hover { border-color: #2e75b6; background: #e8f1fa; }
.upload-mini.has-image {
  border-style: solid;
  border-color: #2e75b6;
  background: white;
  padding: 4px;
  height: 220px;
  min-height: 220px;
}
.upload-mini .placeholder-text {
  pointer-events: none;
}
.upload-mini .upload-mini-label {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 2;
}
.upload-mini .hint {
  font-size: 11px;
  color: #888;
  font-weight: normal;
}
.upload-mini .mini-single {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-mini .mini-single img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.upload-mini .mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  width: 100%;
  height: 100%;
}
.upload-mini .mini-grid > div {
  position: relative;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #f8f9fa;
  border-radius: 4px;
}
.upload-mini .mini-grid .more-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
}
.upload-mini .remove-img {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: rgba(231,76,60,0.9);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 3;
}
.upload-mini .mini-grid > div:hover .remove-img { opacity: 1; }
.upload-mini .add-more {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.25);
  color: white;
  font-size: 26px;
  opacity: 0;
  transition: opacity 0.2s;
  cursor: pointer;
  z-index: 2;
}
.upload-mini:hover .add-more { opacity: 1; }

.controls {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}
.controls label {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.controls input[type=number] {
  width: 80px;
  padding: 4px 8px;
  border: 1px solid #c8d4e0;
  border-radius: 4px;
  font-size: 14px;
}

.status {
  margin-top: 6px;
  font-size: 13px;
  color: #6c7a89;
  min-height: 18px;
}
.status.success { color: #4caf50; }
.status.error { color: #e74c3c; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.thumb {
  background: white;
  border: 1px solid #e0e6eb;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s;
  position: relative;
}
.thumb:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.thumb img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.thumb .info {
  padding: 8px;
  font-size: 12px;
}
.thumb .name {
  font-weight: 500;
  color: #2c3e50;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
}
.thumb .ocr {
  color: #888;
  margin-top: 4px;
  font-size: 10px;
  max-height: 40px;
  overflow: hidden;
  line-height: 1.4;
}
.thumb .delete {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(231, 76, 60, 0.92);
  color: white;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s;
}
.thumb:hover .delete { opacity: 1; }
.thumb .delete:hover { background: #c0392b; }

.thumb .thumb-select {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  z-index: 2;
}

.thumb .index-status {
  position: absolute;
  bottom: 6px;
  left: 6px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  color: white;
  background: #95a5a6;
}
.thumb .index-status.indexed {
  background: #4caf50;
}
.thumb .index-status.pending {
  background: #f39c12;
}

.thumb.selected {
  border-color: #2e75b6;
  box-shadow: 0 0 0 2px rgba(46, 117, 182, 0.3);
}

.lib-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}
.lib-header h2 { margin-bottom: 0; }
.lib-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  background: #2e75b6;
  color: white;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: normal;
  margin-left: 6px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #6c7a89;
  margin-bottom: 8px;
}
.pagination button {
  padding: 4px 12px;
  border: 1px solid #c8d4e0;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button:hover:not(:disabled) { background: #e8f1fa; }
.pagination .btn {
  background: #2e75b6;
  color: white;
  border: 1px solid #2e75b6;
}
.pagination .btn:hover:not(:disabled) { background: #1f4e79; }
.page-jump {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 16px;
  font-size: 13px;
  color: #6c7a89;
}
.page-jump input {
  width: 54px;
  padding: 4px 6px;
  border: 1px solid #c8d4e0;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
}

.results { margin-top: 4px; }
.result-row {
  display: grid;
  grid-template-columns: 60px 220px 1fr 110px;
  gap: 18px;
  align-items: center;
  padding: 14px;
  margin-bottom: 10px;
  background: white;
  border: 1px solid #e0e6eb;
  border-radius: 8px;
  transition: all 0.2s;
}
.result-row:hover {
  background: #f8fbff;
  border-color: #2e75b6;
}
.result-row .rank {
  font-size: 24px;
  font-weight: 700;
  color: #2e75b6;
  text-align: center;
}
.result-row .img-wrap {
  position: relative;
  width: 220px;
  height: 220px;
}
.result-row img {
  width: 220px;
  height: 220px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e0e6eb;
  cursor: zoom-in;
  transition: transform 0.2s;
}
.result-row img:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.result-row .img-wrap .zoom-hint {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.55);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.result-row .img-wrap:hover .zoom-hint { opacity: 1; }
.result-row .meta {
  font-size: 13px;
}
.result-row .filename {
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 6px;
}
.result-row .ocr {
  color: #555;
  line-height: 1.5;
  font-size: 12px;
}
.result-row .scores {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: right;
  font-size: 12px;
}
.result-row .score-final {
  font-size: 18px;
  font-weight: 700;
  color: #2e75b6;
}
.result-row .score-user, .result-row .score-ref {
  color: #888;
}

/* ── 图片放大弹窗 ────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  padding: 40px;
}
.lightbox.active { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 86vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.lightbox .close {
  position: absolute;
  top: 20px;
  right: 28px;
  color: white;
  font-size: 32px;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.lightbox .close:hover { opacity: 1; }
.lightbox .caption {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 14px;
  background: rgba(0,0,0,0.5);
  padding: 6px 16px;
  border-radius: 4px;
  max-width: 80vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #2c3e50;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
}
.toast.show { opacity: 1; }
.toast.success { background: #4caf50; }
.toast.error { background: #e74c3c; }

code {
  background: #f0f3f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

ul { padding-left: 24px; line-height: 1.8; }