.biometric-list {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, 200px);
  justify-content: start;
  margin-top: var(--space-4);
}

.biometric-item {
  width: 200px;
  position: relative;
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-md);
  padding: 0;
  /* Removed padding */
  background: white;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 0;
  /* Reset gap, handle spacing manually */
  /* overflow: hidden; Removed to allow delete button to show outside */
}

.biometric-image-wrapper {
  position: relative;
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-neutral-50);
  /* Match parent radius for top corners */
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  overflow: hidden;
  /* Keep hidden for image corner clipping */
  cursor: pointer;
}

.biometric-image {
  /* Ensure it fills the wrapper for object-cover */
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


/* Add spacing wrapper for content below image */
.biometric-content {
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.biometric-delete-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--color-danger-500, #ef4444);
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  z-index: 10;
  padding: 0;
  transition: background-color 0.2s;
}

.biometric-delete-btn:hover {
  background: var(--color-danger-600, #dc2626);
}

.biometric-name-input {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--color-neutral-300);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  text-align: center;
  background-color: transparent;
  transition: border-color 0.2s;
}

.biometric-name-input:focus {
  outline: none;
  border-color: var(--color-primary-500);
  background-color: white;
}

.biometric-info {
  font-size: var(--text-xs);
  color: var(--color-neutral-500);
  word-break: break-all;
  display: none;
  /* Hide raw key if we have name input, or maybe show it below? */
}

.loading,
.error {
  padding: var(--space-4);
  color: var(--color-neutral-500);
  font-size: var(--text-sm);
}

.error {
  color: #ef4444;
}

.add-new-card {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--color-neutral-300);
  background: var(--color-neutral-50);
  cursor: pointer;
  color: var(--color-neutral-500);
  text-decoration: none;
  aspect-ratio: 1 / 1.3;
  /* Approximate aspect ratio to match items */
  height: 100%;
}

.add-new-card:hover {
  border-color: var(--color-primary-500);
  color: var(--color-primary-500);
  background: var(--color-primary-50);
}

.add-new-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

@media (max-width: 768px) {
  .biometric-list {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 5px;
    grid-template-columns: none;
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
    scrollbar-width: none;
    /* Hide scrollbar for cleaner look */
  }

  .biometric-list::-webkit-scrollbar {
    display: none;
  }

  .biometric-item {
    width: 72px;
    min-width: 72px;
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }

  .biometric-image-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin: 0 auto;
    border: 1px solid var(--color-neutral-300);
  }

  .biometric-image {
    border-radius: 50%;
  }

  .biometric-content {
    padding: 4px 0 0 0;
    gap: 0;
  }

  .biometric-name-input {
    font-size: 11px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: var(--color-neutral-600);
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }

  .biometric-name-input:focus {
    background: white;
    border: 1px solid var(--color-primary-500);
    position: relative;
    /* Bring to front/expand if needed, but simple for now */
    z-index: 10;
  }

  .biometric-delete-btn {
    width: 22px;
    height: 22px;
    top: -2px;
    right: 0px;
    font-size: 14px;
    border-width: 1px;
  }

  .add-new-card {
    width: 64px;
    height: 64px;
    min-width: 64px;
    border-radius: 50%;
    aspect-ratio: 1;
    margin: 0 auto;
    margin-bottom: 20px;
    /* To account for name input space of siblings which pushes bottom */
    /* Actually item wrapper is 72px wide, add card is inside biometric-item normally?
       Wait, let's check controller. 
       Controller: `card.className = 'biometric-item add-new-card';`
    */
  }

  /* Since add-new-card IS the biometric-item in the DOM structure (based on JS: card.className = 'biometric-item add-new-card'), 
     but wait, lines 326: `card.className = 'biometric-item add-new-card';`
     So .biometric-item styles apply. 
     In mobile .biometric-item is 72px wide. 
  */

  .add-new-card.biometric-item {
    width: 64px;
    /* The card itself is the item? No, the card is the A tag. */
    /* JS: card = document.createElement('a'); card.className = 'biometric-item add-new-card'; */
    /* So the A tag IS the item. */
    min-width: 64px;
    height: 64px;
    border-radius: 50%;
    border-style: dashed;
    background: var(--color-neutral-50);
    margin-top: 0;
  }

  .add-new-inner {
    gap: 2px;
  }

  .add-new-inner .biometric-info {
    font-size: 9px;
    display: block;
    line-height: 1;
  }

  .add-new-inner svg {
    width: 20px;
    height: 20px;
  }
}

/* Checkbox for multi-select */
.biometric-checkbox-wrapper {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 11;
}

.biometric-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--color-primary-500, #3b82f6);
}

/* Selected state */
.biometric-item-selected {
  border-color: var(--color-primary-500, #3b82f6);
  box-shadow: 0 0 0 2px var(--color-primary-200, #93c5fd);
}

/* Search button container */
.biometric-search-button-container {
  display: flex;
  justify-content: center;
  margin-top: var(--space-4);
}

.biometric-search-btn {
  min-width: 200px;
}

.biometric-search-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Mobile adjustments for checkbox and selection */
@media (max-width: 768px) {
  .biometric-checkbox-wrapper {
    top: -4px;
    left: -4px;
  }

  .biometric-checkbox {
    width: 18px;
    height: 18px;
  }

  .biometric-item-selected .biometric-image-wrapper {
    border-color: var(--color-primary-500, #3b82f6);
    box-shadow: 0 0 0 2px var(--color-primary-200, #93c5fd);
  }

  .biometric-search-button-container {
    margin-top: var(--space-3);
  }

  .biometric-search-btn {
    min-width: 160px;
    font-size: var(--text-sm);
    padding: 8px 16px;
  }
}
