/* 拼豆图纸生成器：沿用站内工具的卡片 + 左侧标签表单版式，仅补图纸工作区样式 */
.bd-source {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
}

.bd-source-thumb {
  width: 3.25rem;
  height: 3.25rem;
  flex: 0 0 auto;
  border: 1px solid #e2e6ed;
  border-radius: 0.5rem;
  background: #fff;
  object-fit: cover;
}

.bd-source-copy {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.15rem;
}

.bd-source-copy strong,
.bd-source-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bd-source-copy strong {
  color: #343a40;
  font-size: 0.875rem;
}

.bd-source-copy small,
.bd-source > i {
  color: #8a9199;
  font-size: 0.75rem;
}

.bd-dim-input {
  width: 5.2rem;
}

.bd-result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.bd-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.bd-summary-item {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 0.55rem;
  border: 1px solid #e5eaf0;
  border-radius: 0.5rem;
  background: #f8fafc;
}

.bd-summary-item span {
  flex: 0 0 auto;
  color: #8a9199;
  font-size: 0.75rem;
}

.bd-summary-item b {
  overflow: hidden;
  color: #26343f;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bd-editor {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
  padding: 0.55rem;
  border: 1px solid #e5eaf0;
  border-radius: 0.5rem;
  background: #fbfcfd;
}

.bd-editor .form-select {
  width: 4.6rem;
}

.bd-editor .btn.active {
  color: #fff;
  background: var(--site-primary);
  border-color: var(--site-primary);
}

.bd-stage {
  display: grid;
  width: 100%;
  max-height: min(72vh, 52rem);
  min-height: 20rem;
  place-items: start center;
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid #e5eaf0;
  border-radius: 0.5rem;
  background-color: #f7f9fb;
  background-image:
    linear-gradient(45deg, #eef2f5 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f5 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f5 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.bd-stage canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid #dce2e8;
  border-radius: 0.25rem;
  background: #fff;
  box-shadow: 0 2px 10px rgba(33, 45, 56, 0.08);
}

.bd-stage canvas.is-zoomed {
  max-width: none;
}

.bd-stage canvas.is-edit-mode {
  cursor: crosshair;
  touch-action: none;
}

.bd-list-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #e5eaf0;
  border-radius: 0.5rem;
  background: #fff;
}

.bd-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #edf1f4;
  font-size: 0.875rem;
  font-weight: 600;
}

.bd-legend {
  display: grid;
  max-height: min(72vh, 52rem);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 0.4rem;
  padding: 0.55rem;
  overflow: auto;
}

.bd-legend-item {
  display: grid;
  min-width: 0;
  grid-template-columns: 1.35rem 1rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.45rem;
  border: 1px solid #e8edf2;
  border-radius: 0.375rem;
  color: inherit;
  background: #fff;
  font-size: 0.75rem;
  text-align: left;
  cursor: pointer;
}

.bd-legend-item:hover {
  border-color: var(--site-primary-light);
  background: var(--site-tint);
}

.bd-legend-item.is-active {
  border-color: var(--site-primary);
  background: rgba(var(--site-primary-rgb), 0.08);
  box-shadow: inset 2px 0 0 var(--site-primary);
}

.bd-legend-index {
  color: #8a9199;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.6875rem;
  text-align: right;
}

.bd-legend-swatch {
  width: 0.95rem;
  height: 0.95rem;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 0.2rem;
}

.bd-legend-name {
  min-width: 0;
}

.bd-legend-name code {
  display: block;
  overflow: hidden;
  color: #26343f;
  font-size: 0.75rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bd-legend-name small {
  display: block;
  overflow: hidden;
  color: #98a1a9;
  font-size: 0.625rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bd-legend-count {
  color: #64717c;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bd-note {
  margin-top: 0.75rem;
  color: #8a9199;
  font-size: 0.75rem;
}

@media (max-width: 1199.98px) {
  .bd-legend {
    max-height: 22rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 767.98px) {
  .bd-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bd-summary-item {
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.55rem 0.4rem;
  }

  .bd-editor .ms-auto {
    width: 100%;
    margin-left: 0 !important;
  }

  .bd-stage {
    max-height: 62vh;
    min-height: 15rem;
    padding: 0.45rem;
  }

  .bd-legend {
    max-height: 20rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 419.98px) {
  .bd-legend {
    grid-template-columns: 1fr;
  }

  .bd-source-thumb {
    width: 2.75rem;
    height: 2.75rem;
  }
}
